-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add site analytics #151
Add site analytics #151
Conversation
kabilar
commented
Aug 4, 2024
- Create property on the DANDI Google Analytics account
I don't mind. |
@@ -64,6 +64,9 @@ plugins: | |||
# Customize theme | |||
extra: | |||
homepage: https://dandiarchive.org | |||
analytics: | |||
provider: google | |||
property: G-15WQLCLQ3L |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem like a great idea to have this be in the public-facing code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't that ID anyways present somewhere within HTML/JS sources of the page, thus in public facing metadata? yeap:
❯ wget -q -O- https://www.dandiarchive.org/handbook/ | grep G-15WQLCLQ3L
<script id="__analytics">function __md_analytics(){function n(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],n("js",new Date),n("config","G-15WQLCLQ3L"),document.addEventListener("DOMContentLoaded",function(){document.forms.search&&document.forms.search.query.addEventListener("blur",function(){this.value&&n("event","search",{search_term:this.value})}),document$.subscribe(function(){var a=document.forms.feedback;if(void 0!==a)for(var e of a.querySelectorAll("[type=submit]"))e.addEventListener("click",function(e){e.preventDefault();var t=document.location.pathname,e=this.getAttribute("data-md-value");n("event","feedback",{page:t,data:e}),a.firstElementChild.disabled=!0;e=a.querySelector(".md-feedback__note [data-md-value='"+e+"']");e&&(e.hidden=!1)}),a.hidden=!1}),location$.subscribe(function(e){n("config","G-15WQLCLQ3L",{page_path:e.pathname})})});var e=document.createElement("script");e.async=!0,e.src="https://www.googletagmanager.com/gtag/js?id=G-15WQLCLQ3L",document.getElementById("__analytics").insertAdjacentElement("afterEnd",e)}</script>
so IMHO there is really no concern, or what is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks team. I have read that Google Analytics (GA) are set up in both ways. That is, some keep the GA tag in the source code and others use an environment variable. As Yarik mentioned, it is public in the HTML code. The only concern I have seen on a Stackoverflow post (which I can't find now) is that keeping the GA tag in the source code makes it easier if someone wants to spam our GA metrics.
As a team we should decide on the strategy here and keep it consistent across our sites. It looks like the Archive also has a Universal Analytics (legacy) tag in the source code and so does the dandi.github.io repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keeping the GA tag in the source code makes it easier if someone wants to spam our GA metrics.
Or someone spins up a copy of the repo and starts accidentally polluting our GA data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will file some issues in the respective repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed dandi/dandi-archive#2126 as a follow-up to this