data-preservation-programs / slingshot

Official public repository for feedback and data collection in Filecoin Slingshot

Home Page:https://slingshot.filecoin.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

enable google analytics site tracking

dharmapunk82 opened this issue · comments

Please add to document head to enable website analytics for slingshot.filecoin.io:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-EFVL8GP8DW"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-EFVL8GP8DW'); </script>
commented

@dharmapunk82 👋

Will the firing of the analytics tag be configured in GTM? (so that it triggers on both new requests and virtualized navigation)

Since this is a single page app, pages don't make a new GET for every navigation change.

Hi @orvn

Great question!

Initially I planned to just start getting very basic page view data, then integrate GTM later. I hadn't realized you wind up needing to ship the GTM code bits rather than the UA code bits when following google's analytics academy. I've been in the world of AWS and infra as code and whatnot for the last several years, so apologies for the noob ticket on analytics.

After your question I reviewed the docs, and here are the GTM blocks I've configured to feed back to the GA4 analytics property (pls ignore incorrect block in original request, with my thanks):

Paste this code as high in the of the page as possible:
`

<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-KVJWN7R');</script> `

Additionally, paste this code immediately after the opening tag:
`
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KVJWN7R" height="0" width="0" style="display:none;visibility:hidden"></iframe>

`

Thanks again!

Jeff

commented

@dharmapunk82, no worries at all! It doesn't help that modern Javascript apps go against the grain of how analytics tools operate.

Added GTM-KVJWN7R to the site (on both public pages and pages requiring auth).

Are you seeing separate views in Google Analytics on your when you click between pages on the Slingshot site? If not, we might need to create a new trigger for the nuxtRoute event, which will fire every time a user does virtual navigation within the app. Let me know if it looks like it's needed and I can give you the exact values to add in GTM.

Hi @orvn --

I'm happy to confirm that we do see data (since 2/10/22) as I would hope/expect detailing what page elements users are viewing in google analytics now:
image

I think we can consider this resolved, but let me know any follow up questions, especially if there are page elements you would want to see captured that aren't, and we can dig into those. I've configured access for you to view the relevant property and data within analytics.google.com, to double confirm.

Thanks again!

Jeff