Discover Sander's code

001<?php002 003public function get(004   ServerRequestInterface $request005): ResponseInterface {006  $queryParams = $request->getQueryParams();007  $urlParams = $this->determineAnalyticsParameters($queryParams);008 009  if (isset($queryParams['p'])) {010      $urlParams['productId'] = $queryParams['p'];011      return $this->createProductRedirect($urlParams);012  }013 014  return $this->responseFactory->emptyBody(StatusCodeInterface::STATUS_NOT_FOUND);015}016 017 018private function determineAnalyticsParameters(array $queryParams): array019{020  $campaign = [021      'object' => 'product_card',022  ];023 024  if (isset($queryParams['p'])) {025      $campaign['product_id'] = $queryParams['p'];026  }027 028  if (isset($queryParams['l'])) {029      $locationData = explode('.', $queryParams['l']);030      $campaign['store_id'] = $locationData[0];031      if (isset($locationData[1])) {032          $campaign['display_id'] = $locationData[1];033          $campaign['object'] = 'poster';034      }035  }036 037  if (isset($queryParams['s'])) {038      $campaign['slug'] = $queryParams['s'];039  }040 041  $campaignString = '';042  foreach ($campaign as $key => $value) {043      $campaignString .= "[$key:$value]";044  }045 046  return [047    'utm_source' => 'coolblue',048    'utm_medium' => 'qr_stores',049    'utm_campaign' => $campaignString050  ];051}
In-store mode
This is actual code from the Coolblue App. Feel free to scroll through it.
Product cards

Marketing wants to know what kind of QR code was scanned. Most codes are product cards. These are also the smallest. By default, we assume that it's a product_card. So we don't have to indicate that information anymore.

Product ID

We receive the product_id in a parameter 'p'.

The location parameter

The location parameter 'l' can contain a sub location. If so, we separate it with a dot. Period.

Sub location

If there's a sub location, we assume that it's not a product_card, but a poster for a specific product world.

Key-value pairs

The campaign string eventually has multiple key-value pairs, so that these pairs can be separated again in BigQuery.