Skip to content
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

Merged
merged 1 commit into from
Aug 9, 2024
Merged

Add site analytics #151

merged 1 commit into from
Aug 9, 2024

Conversation

kabilar
Copy link
Member

@kabilar kabilar commented Aug 4, 2024

  • Create property on the DANDI Google Analytics account

@yarikoptic
Copy link
Member

I don't mind.

@yarikoptic yarikoptic merged commit 0df3ae4 into dandi:master Aug 9, 2024
2 checks passed
@@ -64,6 +64,9 @@ plugins:
# Customize theme
extra:
homepage: https://dandiarchive.org
analytics:
provider: google
property: G-15WQLCLQ3L
Copy link
Member

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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants