From da87d13a753cdb394fe24a00af7e02f0dcc5fa00 Mon Sep 17 00:00:00 2001 From: Roshan Jossy Date: Mon, 9 May 2022 12:14:36 +0200 Subject: [PATCH] docs(tracking): update external links' source (#711) --- docs/_static/source-in-links.js | 22 ++++++++++++++++++++++ docs/conf.py | 1 + 2 files changed, 23 insertions(+) create mode 100644 docs/_static/source-in-links.js diff --git a/docs/_static/source-in-links.js b/docs/_static/source-in-links.js new file mode 100644 index 000000000..6c3a733eb --- /dev/null +++ b/docs/_static/source-in-links.js @@ -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() +} \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 6f895606c..66edadc4d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -74,6 +74,7 @@ ] html_js_files = [ 'https://cdn.jsdelivr.net/npm/vue@2/dist/vue.min.js', + 'source-in-links.js', ] htmlhelp_basename = slug html_show_sourcelink = False