Table of Contents

About

Trackers are client or server-side libraries which track user behavior by sending events.

Methods

There are two methods of tracking:

  • server-side (Recommended): Events are generated on the server
  • client-side: Events are generated on the client device and sent. There are two types of client-side tracking:
    • web (Javascript)
    • and mobile.
  • You track in one place (your servers) rather than in 3 places (web, iOS, Android)
  • This is more reliable than client-side due to ad-blockers
  • It's also harder to update tracking client side since it might involve redeploying your app to web and mobile clients.
  • You can improve the reliability of client-side tracking using a proxy, but this takes more effort.
  • Client-side tracking is volatile in nature:
    • A user can close a tab during redirection and never come back. You would lose the post-redirect event while if you tracked it server side, you wouldn't 1)
Access to XMLHttpRequest at 'https://api.xxxx' from origin 'https://xxx' 
has been blocked by CORS policy: 
Response to preflight request doesn't pass access control check: 
No 'Access-Control-Allow-Origin' header is present on the requested resource.

Type

Server-side

2)

  • Server side properties: Parse the user agent using a library for your language and get the browser, device, and OS properties.
  • Client Side properties: The non-server side properties need to be added manually to tracked events.
    • UTM parameters from the current URL
    • Referrer information from the browser's document.referrer property
    • IP (Remote Address) on an event, permits to enrich the event via IP geolocalization with city, country, and region properties. For privacy, the IP should not be stored to protect a user's privacy.

Client-Side

The script in a web page should be run in async mode to run early

Many browsers stop executing JavaScript as soon as the page starts unloading, therefore measuring outbound links and forms is difficult.

One solution to this problem is to use:

  • the navigator.sendBeacon() asynchronous method.
  • or for browsers that don't support the beacon transport method, you have to postpone navigating to the next page until the event has finished sending. The Knowing when a hit has been sent section of the guide on Sending data to Google Analytics explains how to do this in detail.

Browser Client-Side Tracking List

3)