Select to view content in your preferred language

ArcGIS Enterprise Sites and Google Analytics

10407
18
03-17-2020 06:37 AM
AlfonsoDodero
Occasional Contributor

Hi ,
in my Company, we are having some issues in monitoring via Google Analytics a web page created with ArcGIS Enterprise Sites.

These were our actions:

  • we have created an Enterprise Site

  • in the edit section, we have entered the Google Analyics tracking ID for one of our google accounts (img. 1)

  •  we have configured our Google Analytics account and its property with the complete site URL
    https://webadaptorhost.domain.it/portal/apps/sites/#/ato
    -> but is not accepted, the error is "the URL must not contain fragment" (img. 2)

  • so we try to insert up to fragment and is accepted by the system

        -> we check the monitoring of the monitoring of the pages by sending test traffic (img. 3)
        -> the site mangement page opens but not traffic is detected

Since the tracking functionality via Google Analytics would natively exist, we are here to asking how to solve and
what we're doing wrong.

Thanks a lot in advance for the help.

18 Replies
Arpa_PiemonteGeoportal_Team
Frequent Contributor

Hi all, we have the same problem and it's a huge problem... any info about release plans ?

At this time the only workaround that we have found is to embed a small js page with the GA codes, in every Sites's page. It works but clearly only for pages where you can embed an iframe: all the major components of Portal for ArcGIS (map viewer, scene viewer, gallery page etc) cannot be monitored.

0 Kudos
FabienLaganne1
New Contributor

Hi, can you tell us more about your workaround ? How do you embed GA js code into Arcgis Site pages ?

Thanks,

fabien

0 Kudos
JeffSchroeder
Emerging Contributor

Would you mind sharing more details of this workaround?  I am interested in what code you inserted and where within the site page to make this work.

DanMcCoy1
Occasional Contributor

@AlfonsoDodero ,

What version of ArcGIS Enterprise were you using?  I am unable to find where you can add a Google Analytics key to an Enterprise Site.... I see it in ArcGIS Online hubs...

Thanks,

Dan

0 Kudos
akochman
Occasional Contributor

I threw the gtag.js script into the index.html file located in C:\Program Files\ArcGIS\Portal\apps\sites on the enterprise server and it seems to be tracking.

Note you need to create a new property in Google Analytics with your enterprise domain, then grab the global site tag you have. Since I only put it on the "sites" specific index.html file, I believe it will only be tracking any ArcGIS Site that I create.

If I want to set it up for the entire domain (ie: the GIS home page and all sub pages), I might try injecting the script into the index.html within "C:\Program Files\ArcGIS\Portal\framework\webapps\arcgis#home", though I haven't tested that yet.

MelissaK
Emerging Contributor

Hello. Thanks for providing the method to track ArcGIS Enterprise Sites, it works for my deployment at 11.3. Have you by any chance tried to change the index.html of Portal home page also? 

0 Kudos
PLadd
by
Frequent Contributor

Anybody hear from ESRI on a solution to this problem?  The issue seems to have gone cold.  It's the end of 2022 and the last post was 10 months ago.  I believe the solution provided by akochman above will work until an upgrade is installed and "C:\Program Files\ArcGIS\Portal\framework\webapps\arcgis#home" is over-written.  It's too bad this feature can exist in Hub but not in Site.  

I tried to search for the bug enhancement number but, like NormWray, could not find it.

AlfonsoDudero's attached image shows a radio button for Google Analytics.  Is this from a newer version of ArcGIS Enterprise than what I am on (10.9.1)?

kreed
by
Emerging Contributor

ENH-000127894 shows that its status is "In Review." During the summer 2022, the status was "In Product Plan." Seems like it was downgraded some time during the past several months. This should be a higher priority, especially since this feature is already in Hub.

0 Kudos
Sweely
by
New Contributor

It sounds like you've run into a common frustration with integrating Google Analytics directly into ArcGIS Enterprise Sites.

The core issue you're experiencing with the URL fragment (`#`) not being accepted in Google Analytics property settings is typical for Single Page Applications (SPAs), which ArcGIS Sites are.

The fragment is used by the application for client-side routing, and traditional Google Analytics setups often struggle to track changes after the hash, seeing it all as one page unless configured otherwise.

The lack of native tracking for all elements, as mentioned by Arpa_PiemonteGeoportal_Team, especially within components like the map and scene viewers, is a significant limitation of the built-in functionality.

The workaround of injecting the `gtag.js` script into the server files, as suggested by akochman, is a valid temporary fix, but as PLadd notes, it is prone to being overwritten during upgrades, making it difficult to maintain.

A more robust and scalable workaround involves using a combination of the ArcGIS APIs, Google Tag Manager (GTM), and a server-side solution, which gives you much finer control over what you track.

First, the ArcGIS API for Python and the underlying ArcGIS REST API can be used to programmatically monitor and gather information about your content and user interactions that happen on the server-side or are exposed via the API, such as item views or downloads, bypassing the front-end GA integration problem entirely for some metrics.

This data can be structured and sent to a data warehouse or directly to a reporting system.

Second, for front-end events and page views that the embedded script misses, the best approach is a server-side tagging solution using Google Tag Manager and a service like Stape or even a custom setup on Google Cloud Platform.

With GTM implemented, you can set up custom events to fire when users interact with the site.

The critical part is using GTM to push these interactions not just to the user's browser but to a server container hosted on Stape or GCP.

This server-side tagging setup is then configured to forward the data to Google Analytics (GA4 is recommended).

This approach addresses the SPA issue by allowing you to manually fire a virtual pageview or Standard Events like `page_view`, `view_item`, or `click` from JavaScript inside the Site pages when the URL hash changes or when a specific action occurs (like opening a map viewer).

Finally, you can bring all this data together using the Google Analytics Data API.

This allows you to programmatically access all the tracked data from your GA property, including the custom events you're sending from your server container, and combine it with the server-side metrics you gather from the ArcGIS REST API.

This method provides a comprehensive view of user behavior across both the core site structure and the richer, dynamic map and scene viewer components that the native GA integration fails to monitor.

While it requires more initial setup and maintenance, this strategy future-proofs your analytics against ArcGIS Enterprise upgrades and provides a depth of tracking not possible with the native, limited feature.

0 Kudos