Please do NOT expect all Feature Requests to be actioned automatically. Describing your proposal here will ensure the development team are aware of it, and they will give it careful consideration.
  • Page:
  • 1

TOPIC:

Support for Google Analytics gtag 1 month 3 days ago #1

  • Tel
  • Tel's Avatar Topic Author
  • Offline
  • New
  • New
  • Posts: 64
Google updated their analytics script to include a new reporting snippet, referred to as gtag.js . The script is similar to the existing Universal Analytics script but includes additional data collection capabilities, including improved data collection across devices (e.g. user engagement across mobile + desktop).

Could an option be included to render the new gtag.js code be included within the Tracking and Analytics modules? While it is possible to manually add the GA script via the custom javascript module, this option does not allow custom dimensions to be dynamically inserted in to the code (e.g.
ga("send", "pageview", {"dimension1":"FamilyName","dimension2":0});
)

The format of the new(ish - since c. 2017) script is:
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'UA-34567890-1');
</script>

Adding custom dimensions via gtag.js (such as FamilyName) is described under Custom Dimensions with gtag.js
Terry
running webtrees 2.0.10 at mynorfolkancestors.net
on PHP 7.4, MySQL 5.6.

Please Log in or Create an account to join the conversation.

Last edit: by Tel.

Support for Google Analytics gtag 1 month 2 days ago #2

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 13716
> Could an option be included to render the new gtag.js code be included within the Tracking and Analytics modules?

Is the new code snippet a backward compatible replacement for the old snippet?
Or do I need to create a different google-analytics module for the new analytics?

Perhaps create an issue at github with all the details.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Support for Google Analytics gtag 1 month 2 days ago #3

  • Tel
  • Tel's Avatar Topic Author
  • Offline
  • New
  • New
  • Posts: 64
Thanks, Greg. I'll raise an issue on Github, although it's not a bug more an update to the latest Google Analytics script.

The new code snippet is a straight slot-in replacement for the old Universal Analytics code snippet. You can use the same GA Account ID, although you can user a new code if you prefer which would generate a new GA Property. Most people are going to use the same Account ID in order to ensure their GA data continues uninterrupted. (Setting up a new GA Property means data only starts flowing in to the associated Views from the date the new Property is created).

I would suggest updating the webtrees Google Analytics module to include a checkbox to the effect 'Do you wish to use the new Google Analytics gtag.js code?' This would give webtrees users the option to continue to use Universal Analytics or the new gtag.js code. By default, Google now includes the new gtag.js script in the Tracking Code section (under Admin > Property Settings) but the GA4 layout is different (see screenshot).

So, while both Google Analytics code snippets will populate your GA account some people may prefer to stick with Universal Analytics. There's an intro to gtag.js (GA4) heregtag.js (GA4) here .


Google Analytics (GA4) web page layout:
Terry
running webtrees 2.0.10 at mynorfolkancestors.net
on PHP 7.4, MySQL 5.6.
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by Tel.
  • Page:
  • 1
Powered by Kunena Forum