Skip to content

Instantly share code, notes, and snippets.

@yieldmo
Forked from emaxerrno/shinji_javascript_tag_urls.js
Last active August 29, 2015 13:55
Show Gist options
  • Select an option

  • Save yieldmo/8700590 to your computer and use it in GitHub Desktop.

Select an option

Save yieldmo/8700590 to your computer and use it in GitHub Desktop.
// this could be minified by their build system
//
(function(window,document){
var tokenizer = function(key, searchString) {
var result = new RegExp(key + "=([^&]*)", "i").exec(searchString || window.location.search);
return result && unescape(result[1]) || "";
};
var clickId = tokenizer('click_id');
if(!clickId || clickId.length < 1){
return;
}
[].forEach.call(document.getElementsByClassName('ym_tag_with_click'),function(element){
// this is only for this advertiser
var input = element.getAttribute('value');
if(input && input.indexOf('click_id') === -1) {
element.setAttribute('value', input + '?click_id=' + clickId);
}
});
})(window,document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment