Google Analytics: Javascript tag

Table of contents

    We provide a fast and simple solution to add the Google Analytics Custom to affiliate links with a JavaScript tag.

    This script will automatically find the Client ID, create the Custom and add to all your affiliate links the Custom according to your settings.

    Install the Javascript Tag

    On Strackr, in the Integrations section, Google Analytics go to the GA Accounts page and click on the JavaScript snippet icon:

    • The JavaScript tag should be added after the Google Analytics tag on each page that you want to track sales.
    • This code will download the JavaScript file and initialize the strackr global function.
    • The command update will add Custom to your affiliate links.

    Custom position

    By default, the script will only add a Custom if the affiliate link have an empty Custom. If the network provide an alternative parameter and you don't use it, the script will add the Custom to the alternative parameter.

    Example with an Awin link:

    The script edit the link:

    But if a network doesn't provide an alternative parameter like Tradetracker, by default, the script will not change your link:

    To track those networks with Google Analytics, the script will have to concatenate your custom + the GAC (example mycustomSTKRgSfhPMjA4MDc4OTQwLjE2NTQ4MTkyMDI=STKR), we use STKR as delimiter at the beginning and the end of the GAC, so if you use the API, in your application you will just have to delete that part.

    Here is an example how to set the Custom positon:

    strackr('create', 'ga', 'STIDTOREPLACE');
    strackr('setting', 'customposition', 'POSITION');

    Replace POSITION by any value according to your needs: default, left, right.

    If you choose right, for the Tradetracker's example you will have YOURINTERNALCUSTOM + STKRgSfhPMjA4MDc4OTQwLjE2NTQ4MTkyMDI=STKR:

    Cloaked affiliate links

    If you cloak your affiliate links and using a redirection page, you can use a helper to create a link with the Custom.

    Install the Javascript tag (you don't need to use the command update) and adjust your code to be able to use the helper:

    // An example of how to use the helper
    function getTrackingUrl(url) {
        if (typeof strackr !== 'undefined') {
            strackr((helper) => {
                var trackingUrl = helper.getUrl(url);
                if (trackingUrl){
                    return trackingUrl;
        return url;
    // Here your redirection process
    window.location.href = getTrackingUrl(url);

    The user will be redirected to the affiliate link with the Google Analytics Custom.

    Use a proxy

    Safari can block third party Javascript to access to the Google Analytics Javascript API, you can use a proxy for your script. A proxy basically maps certain URLs from your domain to the Strackr domain: ->

    When the browser request a file at it will actually be fetched from

    There are many ways you can proxy requests to Strackr depending on your hosting situation, for example with the proxy mode of Apache2 or Nginix. A standalone proxy can be set up on its own and it does not matter what hosting provider or tech stack you are using. Integrated proxy setups are dependent on how you've deployed your app.

    Available networks

    Here is a list of available networks in the Javascript tag:

    • Awin
    • Daysicon
    • Tradetracker
    • Shareasale
    • Kwanko
    • Adtraction
    • Adrecord
    • Webgains
    • Flexoffers
    • Admitad
    • eBay Partner Network
    • Effiliation
    • Rakuten Marketing
    • Sovrn commerce
    • financeAds
    • CommunicationAds
    • Tradedoubler
    • Partnerize
    • CJ Affiliate
    • Kelkoo
    • Affilae
    • retailAds

    If there is a missing network, please contact us with an URL example and the subid, we will add it.

    Get started for free

    30 days free trial, no credit card required. Connect to your networks within minutes — and cancel anytime.

    Try for free

    Try the live demo

    Not quite ready to sign up? Take a test drive of the Strackr dashboard in our interactive live demo.

    See the live demo

    Still have questions?

    If there’s anything else you want to know about Strackr, contact us and we’ll be happy to fill you in.

    Contact us