Last active
November 8, 2023 08:16
-
-
Save webhasan/a1d968862ce47498b8baf572eb19d7a9 to your computer and use it in GitHub Desktop.
Affiliate Link Tracking with GTM Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example affiliate link | |
// https://leocoder-shop.myshopify.com?affiliate_id=rubel | |
// set affiliate id | |
var queryParts = new URLSearchParams(window.location.search); | |
var affiliate_id = queryParts.get('affiliate_id'); | |
if(affiliate_id) { | |
localStorage.setItem('affiliateId', affiliate_id); | |
} | |
// collect affliate id | |
localStorage.getItem('affiliateId'); | |
// remove affiliate id | |
localStorage.removeItem('affiliateId'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment