Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTM Preview mode not supported? #21

Open
mark-at-tusksoft opened this issue Sep 23, 2020 · 4 comments
Open

GTM Preview mode not supported? #21

mark-at-tusksoft opened this issue Sep 23, 2020 · 4 comments
Labels
question Further information is requested

Comments

@mark-at-tusksoft
Copy link

mark-at-tusksoft commented Sep 23, 2020

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.

@mark-at-tusksoft
Copy link
Author

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

@isc30
Copy link
Owner

isc30 commented Sep 24, 2020

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?

@isc30 isc30 added the question Further information is requested label Sep 24, 2020
@mark-at-tusksoft
Copy link
Author

mark-at-tusksoft commented Sep 24, 2020

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.

@pmonte
Copy link

pmonte commented Jul 23, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants