Created
July 18, 2021 04:39
-
-
Save atikju/3b86e77ff49645c9c6b3b4b0c5e5ef53 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
if (window.location.search != '') { | |
var fb_campaign_id = ''; | |
var search_items = window.location.search; | |
search_items = search_items.replace('?', ''); | |
search_items = search_items.split('&&'); | |
for(i=0;i<search_items.length;i++){ | |
var thisItem = search_items[i]; | |
if(thisItem.indexOf('utm_medium') > -1){ | |
var getCampaign = thisItem.split("="); | |
fb_campaign_id = getCampaign[1]; | |
var buyLinkList = document.getElementsByClassName('buyBtn'); | |
for(i=0;i<buyLinkList.length;i++){ | |
var newURL = buyLinkList[i].href+'?attributes[fb_campaign_id]='+fb_campaign_id; | |
buyLinkList[i].href=newURL; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment