# Track Query String Params

## Overview

Track when a page is accessed with a specific query string parameter, and store that value for later.&#x20;

*Very useful for affiliate tracking.*

## Implementing

Place this in the /BODY custom code area of the page you're expecting the querystring on; or in your site-wide custom code if any page could receive it.&#x20;

{% code overflow="wrap" %}

```html
  <script>
  $(function() {
  
    // Check the URL to see if we have any referral info to track 
    if (location.search != "") {
      console.log("querystring found.");
      const urlParams = new URLSearchParams(location.search);
    
      if(urlParams.has('referrer')) {
        window.tracker.track("referrer", urlParams.get("referrer")); 
      }
    
    }
  });
  </script>
```

{% endcode %}

To access the referrer code, you can just retrieve it where you need it;

```javascript
window.tracker.getItem(`referrer`)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://attr.sygnal.com/sa5-track/webflow-cookies-and-storage-tracking/track-query-string-params.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
