Select to view content in your preferred language

Provide ability to track ArcGIS Experience Builder interactions with Google Analytics

14137
52
10-19-2020 10:20 AM
Status: Open
PeterKnoop
MVP Regular Contributor

Add support for Google Analytics to Experience Builder. Keep it simple, as was done in StoryMaps and Hub, where you have a setting or property for each Experience into which you can paste your Google Analytics Tracking ID.

[Original GeoNet thread: Google Analytics with Experience Builder?]

52 Comments
PeterKnoop

@FredericPoliart_EsriAU just to confirm then, if you happen to be using Experience Builder Developer Edition, then there is a workaround. You can place the google analytics script in its required location in <head>, as you are able to directly edit pages' html.

There is no workaround for regular Experience Builder.

FredericPoliart_EsriAU

If you are using Experience Builder Developer edition, you can also use this:

https://blog.saeloun.com/2022/02/17/how-to-integrate-react-app-with-google-analytics.html

You won't be able to add Google Analytics with the AGOL-only version of Experience Builder (for now), unless you use the <embed> widget 

PeterKnoop

@FredericPoliart_EsriAU would you be able to provide more details on how one can use the <embed> widget with Experience Builder in ArcGIS Online to add Google Analytics?

Pasting Google's JavaScript snippet for a tag into the code block for an Embed widget does not work for me. 

 

FredericPoliart_EsriAU

@PeterKnoop  Try the following:

1. open your experience builder (the welcome window "terms and conditions" or the main page)

2. add an <embed> widget

3. in the Embed Content tab, select " code"

4. paste the following

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src=https://www.googletagmanager.com/gtag/js?id=G-DH7XXWBZ2G></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-DH7XXWBZ2G');
gtag('event', 'Terms and Conditions', {
'event_category' : 'FRED_TEST',
'event_label' : 'pknoop'
});
</script>


5. the rectangle will be hollow : make it very small 8x8pixels and hide it somewhere

6. Save, publish,

7. test and look at your Google Analytics : select Reporting realtime so you can see the 1 appearing (you)

8. Start Google Chrome Debug window (F12) and look for a network packet going to https://www.googletagmanager.com/gtag/js?id=G-1TMxxxxBC0  

 

 

FredericPoliart_EsriAU_0-1665578999311.png

[!] your GoogleAnalytics Tag ID will be different, of course.  You must replace my G-DH7XXWBZ2G above .

 

When you 

FredericPoliart_EsriAU

I am just testing it now .  I created a new Experience Builder (online, not the dev edition)
and I added the embed tag.     It's actually on https://experience.arcgis.com/experience/ 

I can see the result in Google Analytics:

FredericPoliart_EsriAU_0-1665579901821.png

and the Google Chrome network analysis does show the ExB app fetching/sending something to GA 

FredericPoliart_EsriAU_0-1665580012067.png

 

ChelseaDickerson1

Yes, this would be great! It's almost 2023, the fact that we can't get detailed analytics for all AGOL content is sad!

SanchezNuñez

I agree, we need Google Analytics in EB.

JornSijbertsma

Yes great idea - getting insight how to platform/app is used, this is major! Another suggestion is getting  Google Analytics for ArcGIS Enterprise Platform to see the different types of consumption (internally/externally) .

JulioGarrido

@FredericPoliart_EsriAU I have tried your method by modifying your HTML code to use our "G-" code as well as using the code provided by Google Analytics.  Neither HTML code worked for us.  I'm wondering if it's because Google Analytics is moving from a "UA" environment to a "GA4" environment or EB does not support this type of functionality.

Either way, thank you for posting a possible solution. EB needs to have a simpler way to add Google Analytics similar to that of ArcGIS Hub. We are using EB for our public map. It would be nice to see the traffic.

Galen
by

@JulioGarrido, We didn't have luck with @FredericPoliart_EsriAU code either. I am not sure that the script tags are supported in the embed code. Analytics integration would be a great enhancement to ExB.