Project

General

Profile

Feature #21220

Updated by Peter Amstutz 10 months ago

Add a configuration setting to Workbench 2 that supports a Google Tag. If set, Workbench 2 generates the necessary HTML to load and report to Google Analytics using that tag. 

 Version 1 of this integration can be the simplest possible integration: it just needs to report when someone loads Workbench. More detailed activity tracking can be done in a follow-up story. 

 "The necessary HTML is below.":https://developers.google.com/tag-platform/gtagjs/install @TAG_ID@ is the value from configuration anywhere it appears. 

 <pre><code class="html"> 
   <!-- Google tag (gtag.js) --> 
   <script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script> 
   <script> 
     window.dataLayer = window.dataLayer || []; 
     function gtag(){dataLayer.push(arguments);} 
     gtag('js', new Date()); 

     gtag('config', 'TAG_ID'); 
   </script> 
 </code></pre> 

 There's also a package to integrate react with Google Analytics 4, which tracks navigation actions within the app: 

 https://www.npmjs.com/package/react-ga4 

 h2. Implementation 

 Need to add an public exported config item to the Workbench section that has the google analytics tag. 

 Once we have retrieved the configuration, we can set up react-ga4 in the init function. 

Back