My request is more for Twitch support, but may be community also can help me
We have been experiencing issues as the current guidelines provided are tailored for older versions, resulting in our analytics not working properly. With the discontinuation of Universal Analytics in favour of GA4 at Google’s initiative, it’s vital that we have accurate, updated instructions that reflect the latest standards and capabilities of Google Analytics. We are experiencing problems because the current instructions provided are tailored to older versions, resulting in our analytics not working properly.
Specifically, we are experiencing issues with data transfer to GA4 via the analytics.js connection. Data is not being transferred to our GA4 stream and in order for GA4 to work properly we need the ability to connect via gtag.js within our extension.
Could you please provide us with the necessary documentation or any updates on how to effectively integrate GA4 into Twitch extensions?
Could you please provide us with the necessary documentation or any updates on how to effectively integrate GA4 using gtag.js?
We have reviewed the discussion in the GitHub issue #689, where your team acknowledged the limitations and mentioned that the use of gtag.js
is not currently supported due to Content Security Policy restrictions.
Unfortunately, this situation makes it impossible for us to fully rely on Google Analytics 4 (GA4) within our extension, as Universal Analytics is deprecated and analytics.js
no longer provides the expected data continuity and accuracy.
Could you please provide us with:
- A more concrete update or timeline regarding potential CSP updates that would allow using
gtag.js
in extensions?
- Any temporary best practices or recommendations for achieving accurate tracking in the meantime?
That is how you use GA4. And works fine in my own extensions, which was how/why I wrote that comment on that GitHub.
As noted in the other comment in that thread here Google Analytics in Extensions - July 2023 deadline · Issue #689 · twitchdev/issues · GitHub
Update your header to includes
<script async src="https://www.googletagmanager.com/gtag/js?id=GCODE"></script>
In your JS
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GCODE', { 'anonymize_ip': true, 'cookie_flags': 'max-age=7200;secure;samesite=none' });
Thats it and works fine for me. There is no CSP issue here.
Google Analytics 4 is supported and not blocked by CSP.
So:
Google Analytics 4 is supported and not blocked by CSP
There is no timeline as the work has been completed in advance of the shutdown deadline from Google.
Since GA4 is not blocked by CSP, use GA4
This directly linked comment contains the proposed documentation changes.
This ticket is closed as the CSP has been revised. Just the documentation has not