US-GHG-Center / veda-config-ghg

Veda config for GHG
https://ghg-demo.netlify.app
Other
3 stars 14 forks source link

Google Tag Manager and new E&A #376

Closed aboydnw closed 1 month ago

aboydnw commented 1 month ago

Doing some testing in google tag manager now that the new E&A feature is on production for GHG, and it does not play nicely with google tag manager at all. Since IMPACT reports these metrics directly to HQ and GHG Center, I'm hoping to get some assistance rather quickly.

I originally followed this article when setting up our GTM instance. The section at the bottom is one idea for how we can address this. I avoided this path in the past, because I could manage everything without developer intervention, but now I think that has changed.

Basically, because this is a single page app, we track page views in our VEDA Dashboards by monitoring history change. Usually, this works quite well. The new E&A interface must be extra complex or something, because once I click Add to Map it fires off a whole bunch of history changes that, to google tag manager, are not noticeably different. It seems tied to the number of layers I choose to visualize. I also noticed that when I adjust the zoom slider, it also fires a history change and subsequent page view. So, our page views will be vastly overinflated if we leave it like this.

cc @hanbyul-here @sandrahoang686 @dzole0311

aboydnw commented 1 month ago

Early results of this problem, you can see in this screenshot that for the exploration pages there are significantly more views than sessions. Which could skew our numbers quite a bit. Right now, not many people are using this feature. As we have webinars, focus groups, and newsletters, that will change. So, I'd like to fix this before that happens. image

aboydnw commented 1 month ago

Here is the example code snippet that they suggested in the attached article. Basically, they suggest to activate a dataLayer.push code whenever a user navigates between pages/states the app.

<script>
 window.dataLayer = window.dataLayer || [];
 window.dataLayer.push({
 'event': 'virtualPageview',
 'pageUrl': 'https://www.mywebsite.com/something/?page#contact-us',
 'pageTitle': 'Contact us' //some arbitrary name for the page/state
 });
</script>
aboydnw commented 1 month ago

I added a workaround for now to exclude page views for any exploration page that includes URL parameter. It gives us a little less visibility into certain behaviors, like most popular datasets to explore, but resolves the immediate issue here. Closing for now unless we see this problem be more persistent across the app or we really want that additional visibility.