T
tejdi
Guest
Does MyAcc work with the new google analytics? (GA4)
It shows that my website doesn't send any data (trying to access it from a phone on LTE and computer).
I've copied the code from GA4 and added it to the config, here:
However, the new code is in a different format.
Old GA code: UA-XXXXXXX-X
New GA code: G-XXXXXXXXXX
Ok, looks like I've found a fix:
Find google_analytics.html.twig and paste:
Then go to functions.php and find:
and place under it:
then find:
and comment out the line below:
Enjoy your working GA4
It shows that my website doesn't send any data (trying to access it from a phone on LTE and computer).
I've copied the code from GA4 and added it to the config, here:
PHP:
'google_analytics_id' => '',
However, the new code is in a different format.
Old GA code: UA-XXXXXXX-X
New GA code: G-XXXXXXXXXX
Post automatically merged:
Ok, looks like I've found a fix:
Find google_analytics.html.twig and paste:
HTML:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ config.google_analytics_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ config.google_analytics_id }}');
</script>
Then go to functions.php and find:
PHP:
if($type === 'head_start') {
PHP:
$ret .= template_ga_code();
PHP:
elseif($type === 'body_end') {
PHP:
//$ret .= template_ga_code();
Enjoy your working GA4
Last edited by a moderator: