File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <% # Add UTM parameters to ` <a>` links.
2+
3+ # Notes:
4+ - ` utm_medium=partnership` is added to Sketchy links.
5+ - ` utm_source=ankihub` is added to other links.
6+
7+ _%>
8+
9+ <script >
10+ for (const anchor of document .querySelectorAll (" a" )) {
11+ try {
12+ const url = new URL (anchor .href );
13+ if (! url .protocol .startsWith (" http" )) {
14+ continue ;
15+ }
16+ const params = new Map ();
17+ if (url .hostname .endsWith (" sketchy.com" )) {
18+ params .set (" utm_medium" , " partnership" );
19+ } else {
20+ params .set (" utm_source" , " ankihub" );
21+ }
22+ for (const [key , value ] of params .entries ()) {
23+ if (! url .searchParams .get (key)) {
24+ url .searchParams .set (key, value);
25+ }
26+ }
27+ anchor .href = url .toString ();
28+ } catch {
29+
30+ }
31+ }
32+ </script >
Original file line number Diff line number Diff line change @@ -168,3 +168,5 @@ replace the arrows/dashes from the statement below with double curly brackets-->
168168<% - include (' src/components/imageBlur.ejs' ) %>
169169
170170<% - include (' src/components/shuffleItems.ejs' ) %>
171+
172+ <% - include (' src/components/addUtmParameters.ejs' ) %>
Original file line number Diff line number Diff line change @@ -46,4 +46,6 @@ var autoflip = false
4646 qFade= 0 ; if (typeof anki !== ' undefined' ) anki .qFade = qFade;
4747 </script >
4848
49- <% - include (' src/components/colorfulTags.ejs' ) %>
49+ <% - include (' src/components/colorfulTags.ejs' ) %>
50+
51+ <% - include (' src/components/addUtmParameters.ejs' ) %>
You can’t perform that action at this time.
0 commit comments