-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(tracking): update external links' source (#711)
- Loading branch information
Roshan Jossy
authored
May 9, 2022
1 parent
099e221
commit da87d13
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function addUTMSourceToLink(href) { | ||
try { | ||
var url = new URL(href); | ||
url.searchParams.set("utm_source", "clip-as-service"); | ||
return url.href | ||
} | ||
catch{ | ||
return href | ||
} | ||
} | ||
|
||
function addUTMSourceToLinks() { | ||
var anchors = document.getElementsByTagName("a"); | ||
|
||
for (var i = 0; i < anchors.length; i++) { | ||
anchors[i].href = addUTMSourceToLink(anchors[i].href) | ||
} | ||
} | ||
|
||
window.onload = function () { | ||
addUTMSourceToLinks() | ||
} |
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