Last active
September 28, 2025 20:36
-
-
Save erinrwhite/c77eefc786fb2574160c21d30ef9e61a to your computer and use it in GitHub Desktop.
SimpleAnalytics implementation with tracking gif - adding variables using local JS
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
| <!-- SimpleAnalytics with some added info --> | |
| <script type="text/javascript"> | |
| const analyticsURL = "https://queue.simpleanalyticscdn.com/noscript.gif"; | |
| const refURL = document.referrer; | |
| const hostName = encodeURI(window.location.hostname); | |
| const pathName = encodeURI(window.location.pathname); | |
| const userTZ = Intl.DateTimeFormat().resolvedOptions().timeZone; | |
| const imageTag = document.createElement("img"); | |
| imageTag.setAttribute("alt",""); | |
| imageTag.setAttribute("referrerpolicy","no-referrer-when-downgrade"); | |
| imageTag.setAttribute("src",analyticsURL+"?hostname="+hostName+"&path="+pathName+"&referrer="+refURL+"&timezone="+userTZ); | |
| document.body.appendChild(imageTag); | |
| </script> | |
| <noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade"/></noscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment