# 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.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcQsT_SCZnQmuCPB35TAKc5xsovwU1vuh6N97b2wCKJtPhyIT38hfRQsciWdkff7Xxf969qRYmpIsE2uJmjYUVercCf9lxc3N0b6bw157ncqbBFNMuE4fR8udtjGiSfZhQ_tmLIFA?key=vC8Fe0sabjWE3xktDp_uXg2B" alt=""><figcaption></figcaption></figure>

***

### 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>
```

&#x20;   \
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.

2. **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.

\
