Last active
September 4, 2018 10:54
-
-
Save agarbund/5436ddfacd9f4d0b5ba4e90c362fb5a3 to your computer and use it in GitHub Desktop.
Revisions
-
agarbund revised this gist
Sep 4, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ $(document).ready(function() { $('a').each(function() { var link = this.href, prefix, params = ''; if( link.match(domainRegexp) && !link.match(/[?&]utm_/) ) { prefix = link.match(/\?/) ? '&' : '?'; -
agarbund revised this gist
Sep 4, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // 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 + '=([^&]+)')); -
agarbund revised this gist
Sep 4, 2018 . 1 changed file with 19 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,24 @@ // 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 = 'yulife.com'; 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]); } }); if(utmStrings.length) { $('a').each(function() { var link = this.href, prefix, params = ''; if( link.match(/yulife\.com[/$]/) && !link.match(/[?&]utm_/) ) { prefix = link.match(/\?/) ? '&' : '?'; this.href = link + prefix + utmStrings.join('&'); } }); } }); -
agarbund revised this gist
Sep 4, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ $(document).ready(function() { var utmMedium = ''; // put utm_medium value here var utmSource = ''; // put utm_source value here var domain = ''; // put domain here (utm params will be added only to links from that domain) var domainRegexp = new RegExp(domain.replace(/\./g, '\\.')); $('a').each(function() { -
agarbund revised this gist
Sep 4, 2018 . 2 changed files with 0 additions and 60 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,60 +0,0 @@ File renamed without changes. -
agarbund created this gist
Sep 4, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>JS Bin</title> </head> <body> <script src="https://code.jquery.com/jquery-2.2.4.js"></script> <a href="https://www.yulife.com/some/link">Some link</a> <a href="https://www.yulife.com/another-link/">Another link</a> <a href="https://www.yulife.com">Main page</a> <a href="https://www.yulife.com/">Slash</a> <a href="https://yulife.com/">No wwww</a> <a href="https://yulife.com/">No wwww</a> <a href="https://yulife.com/?utm_medium=abc">With UTM</a> <a href="https://yulife.com/?haha=hoho&utm_medium=abc">With UTM 2</a> <a href="https://yulife.com/?haha=hoho">Params no UTM</a> <a href="https://yahoo.com/">Not yulife</a> <a href="https://yulife.commercial.com/">Not yulife</a> <script id="jsbin-javascript"> $(document).ready(function() { var utmMedium = 'referral'; var utmSource = 'ladder_landing_book_a_demo'; var domain = 'yulife.com'; var domainRegexp = new RegExp(domain.replace(/\./g, '\\.')); $('a').each(function() { var link = this.href, prefix; if( link.match(/yulife\.com[/$]/) && !link.match(/[?&]utm_/) ) { prefix = link.match(/\?/) ? '&' : '?'; this.href = link + prefix + 'utm_medium=' + utmMedium + '&utm_source=' + utmSource; } }); }); </script> <script id="jsbin-source-javascript" type="text/javascript">$(document).ready(function() { var utmMedium = 'referral'; var utmSource = 'ladder_landing_book_a_demo'; var domain = 'yulife.com'; var domainRegexp = new RegExp(domain.replace(/\./g, '\\.')); $('a').each(function() { var link = this.href, prefix; if( link.match(/yulife\.com[/$]/) && !link.match(/[?&]utm_/) ) { prefix = link.match(/\?/) ? '&' : '?'; this.href = link + prefix + 'utm_medium=' + utmMedium + '&utm_source=' + utmSource; } }); });</script></body> </html> 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ $(document).ready(function() { var utmMedium = 'referral'; var utmSource = 'ladder_landing_book_a_demo'; var domain = 'yulife.com'; var domainRegexp = new RegExp(domain.replace(/\./g, '\\.')); $('a').each(function() { var link = this.href, prefix; if( link.match(/yulife\.com[/$]/) && !link.match(/[?&]utm_/) ) { prefix = link.match(/\?/) ? '&' : '?'; this.href = link + prefix + 'utm_medium=' + utmMedium + '&utm_source=' + utmSource; } }); });