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
// script which reads UTM params from the URL and adds them to all links on the current page | |
$(document).ready(function() { | |
var utms = ['medium', 'source', 'campaign', 'term', 'content'], utmStrings = []; | |
var domain = ''; // add domain here, only links to given domain will be siffixed with utm params | |
var domainRegexp = new RegExp(domain.replace(/\./g, '\\.')); | |
utms.forEach(function(utm) { | |
var match = window.location.search.match(new RegExp('utm_' + utm + '=([^&]+)')); | |
if(match) { | |
utmStrings.push('utm_' + utm + '=' + match[1]); | |
} |