GTM Preview mode not supported?
This may be an issue separate from Blazor-Analytics (let me know if you agree). When trying to view the BlazorClient site in preview mode using GTM, the expected panel does not appear. Is this just an incompatibility with Blazor? I'm not sure if GTM needs to inject additional js to make this functionality work or if it is supposed to be included in the initial analytics scripts from the head element to insert the preview/debug iframe.
Found the issue.
GoogleAnalytics/Resources/GoogleAnalyticsInterop.ts line 25
script.src = "https://www.googletagmanager.com/gtag/js?id=" + trackingId;
looks like this should be
script.src = "https://www.googletagmanager.com/gtm.js?id=" + trackingId;
I get a 403 when it is /gtag/js instead of /gtm.js
Hi Mark, please correct me if I'm wrong.
The library only supports GTAG atm, which is implemented inside GoogleAnalyticsInterop.ts.
If you wanted to use GTM, a new integration would need to be added since the apis are different.
I also found that some browsers with adblockers block the gtag.js script from being loaded, can you check if that's your case?
This is very likely a result of my ignorance around Google services. I was unaware there was a difference. Perhaps the 403 I was getting was due to .../gtag/js being handed a GTM id.
How involved of a process would it be to include GTM? I kinda see how it would be done from the Blazor-side of the Blazor-Analytics infrastructure but my experience with GTM is rather limited so I am oblivious to how much work would be required for the typescript wrapper.
I also needed GTM support so I forked the repo and tried to support it. It is far to be perfect (for example variables to use in GTM for events and events name are hardcoded) but could be a starting point: https://github.com/pmonte/blazor-analytics