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.
On Strackr, in the Integrations section, Google Analytics go to the GA Accounts page and click on the JavaScript snippet icon:
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:
https://www.awin1.com/cread.php?awinmid=XXXX&awinaffid=AAAA&clickref=YOURINTERNALCUSTOM&ued=https%3A%2F%2Fwww.google.com%2F
The script edit the link:
https://www.awin1.com/cread.php?awinmid=XXXX&awinaffid=AAAA&clickref=YOURINTERNALCUSTOM&ued=https%3A%2F%2Fwww.google.com%2F&clickref2=STKRgSfhPMjA4MDc4OTQwLjE2NTQ4MTkyMDI=STKR
But if a network doesn't provide an alternative parameter like Tradetracker, by default, the script will not change your link:
https://tc.tradetracker.net/?c=WWW&m=AAA&a=QQQQ&u=%2Ffr&r=YOURINTERNALCUSTOM
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');
strackr('update');
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
:
https://tc.tradetracker.net/?c=WWW&m=AAA&a=QQQQ&u=%2Ffr&r=YOURINTERNALCUSTOMSTKRgSfhPMjA4MDc4OTQwLjE2NTQ4MTkyMDI=STKR
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.
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:
https://yourdomain.com
When the browser request a file at https://yourdomain.com
it will actually be fetched from https://cdn.strackr.com/integrations/bundle.min.js
.
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.
Here is a list of available networks in the Javascript tag:
If there is a missing network, please contact us with an URL example and the subid, we will add it.
30 days free trial, no credit card required. Connect to your networks within minutes — and cancel anytime.
Not quite ready to sign up? Take a test drive of the Strackr dashboard in our interactive live demo.
If there’s anything else you want to know about Strackr, contact us and we’ll be happy to fill you in.