> For the complete documentation index, see [llms.txt](https://docs.sprinthub.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sprinthub.com/en/topics/api/api-advanced-advanced-tracking-via-tracking-script.md).

# API - (Advanced) Advanced Tracking via Tracking Script

Go to **System Settings > System > Tracking**:

<figure><img src="https://684109703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FzUKkagBNy5uQ7AtGNa%2Fuploads%2FQNnUujjvKH2lPxRqdpHT%2FCaptura%20de%20Tela%202023-11-07%20a%CC%80s%2017.45.41.png?alt=media&amp;token=f4d441ab-ecd0-47be-bfac-705d51657ce1" alt="" width="563"><figcaption></figcaption></figure>

```javascript
<script 
  iname="YOUR_LICENSE"
  src="https://YOUR_LICENSE.sprinthub.app/js/shubfull.min.js"
  burl="https://sprinthub-api-master.sprinthub.app">
</script>
```

You will have access to your Tracking Script as shown above. You can insert this Script into any website or web system, always within the tag **\<body>** and or before closing the **\</body>**.

With this script, you will send your Leads' browsing information into your **SprintHub**. Any Lead that accesses a site containing this Script will generate an Anonymous Lead within the **SprintHub**, which will track all pages this Lead visited.

If on the same day or after a few days, this Lead returns to your site and decides to sign up in some form, where this Lead registration will be sent into your **SprintHub**, the system will make a *Merge* between the Anonymous Lead from the past and the new Lead that just signed up. In other words, you can know exactly what this Lead did on your site even before it became an identified Lead in the **SprintHub**.

Therefore, if you are not using a Landing Page created in the **SprintHub**, it is highly recommended that you add this script to your site and or system.

### Now for the most advanced part! (For developers)

Let's say you have an E-commerce or your own System where your Leads log in with username and password. It is possible, via tracking script, to create and or identify the Lead that logged in, using the email or username.

Obviously you need to have access to the variables in your system that bring this information to the browser. With these variables in hand, you can send to SprintHub, via tracking script:

**Example**:

```javascript
<script>
    window.sprint.recordLeadData({
    firstname: "{{user_name}}",
    lastname: "{{user_lastName}}",
    email: "{{user_email}},
    tags: ["{{course_name}}","{{classRoom_name}}"]
});
</script>
```

The variables within **{{ }}**, are examples of any system. You will need to know the system to know how and what those variables are.

This script above must come **AFTER** the main tracking script. But both need to be inside **\<body>**.

Once that's done, you will be identifying your Lead within the **SprintHub**, since they may enter your system through a browser/device that is not being tracked.

If the Lead above has the same email as an existing Lead, you can merge the information from both within the **SprintHub** automatically or manually.

The method of ***Advanced Tracking*** above can be used, for example, for cart recovery.&#x20;

**Imagine the following hypothetical situation, but one that commonly occurs**: The Lead enters your site (ecommerce), logs in, and starts adding products to the Shopping Cart. They reach Checkout and when they see the shipping price, they give up on completing the purchase.

With ***Advanced Tracking*** of the **SprintHub** properly configured, you are already sending this information to the **SprintHub**. The cart items, for example, you can send as Tags or as Custom Objects. Thus, you can create an Automation flow where the **SprintHub** can send an email or WhatsApp to this Lead after 1 hour of cart abandonment, containing a discount coupon so they come back and complete their purchase.&#x20;

This is just **ONE example**, but the possibilities are numerous.

**NOTE:** If you use proprietary systems such as Woocommerce, Magento, Hotmart, Vtex, where you will probably not know the variables to send to SprintHub, we recommend doing this via API, using systems like N8N, Zapier, or Make.
