Web tracker

Overview

The Website Tracker allows users to monitor and analyze website activity by integrating a tracking script into their web pages. This guide provides detailed steps for setting up the tracker and configuring essential tracking events to ensure seamless data synchronization.


Prerequisites

Before setting up the website tracker, ensure you have:

  • Access to your website's source code.

  • Permission to add scripts to the website.

  • A valid tracker script URL provided by your analytics provider.


Step 1: Integrate the Tracking Script

To enable website tracking, insert the provided JavaScript code before the closing </head> tag of your website.

Example Tracking Script:

// <script type="text/javascript">

 fetch("https://pndev.proemsportsanalytics.com/api/ccgt/tracker/web/")
      .then((response) => response.json())
      .then((data) => {
        const isTrackingEnabled = data.constants === 'p' ? true : false;
        if (isTrackingEnabled) {
          (function (p, l, o, w, i, n, g) {
            if (!p[i]) {
              p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || [];
              p.GlobalSnowplowNamespace.push(i);
              p[i] = function () {
                (p[i].q = p[i].q || []).push(arguments);
              };
              p[i].q = p[i].q || [];
              n = l.createElement(o);
              g = l.getElementsByTagName(o)[0];
              n.async = 1;
              n.src = w;
              g.parentNode.insertBefore(n, g);
            }
          })(
            window,
            document,
            "script",
            "https://psa-sp.s3.ap-south-1.amazonaws.com/psa_tracker.js",
            "snowplow"
          );
          snowplow("environment", club-platform, "psa_sdk.proemsportsanalytics.com", {
            appId: "App-ID",
            platform: "web",
            contexts: {
              webPage: true,
              performanceTiming: true,
            },
          });
        }
      });
  </script>

Instructions:

  1. Copy the provided script.

  2. Paste it before the closing </head> tag on every page where tracking is required.

  3. Save and publish your website changes.

This script loads asynchronously, ensuring that website performance is not affected.


Step 2: Implement Tracking Events

After initializing the tracker, you must implement specific tracking events to monitor user activity.

Example Tracking Events:

snowplow('setUserId', "USER_ID");

snowplow("trackPageView");

Required Events:

  1. setUserId: Assigns a unique identifier to the user.

  • Replace USER_ID with the actual user ID from your system.

  • If no ID is available, pass null.

  1. trackPageView: Logs a page view event whenever a user navigates to a new page.

  • This function should be called on every page load.


Troubleshooting

  • Tracker not loading? Ensure the script is correctly placed before </body>.

  • Events not firing? Check for JavaScript errors in the browser console.

  • Incorrect user ID? Ensure setUserId is called with the correct value.

  • Slow performance? Confirm the tracker script is loading asynchronously.

Following these steps will ensure proper setup and accurate event tracking for your website.

Last updated