I've been trying to setup Google Analytics and according their website you're supposed to just insert their script into your html page.
I've added this into my base.html.twig file right after the opening tag. This is then extended by the layout.html.twig file which is extended by all other pages.
This isn't showing up as installed from the Google Analytics page. The tag shows in the page source and is being blocked by Ghostery yet it still shows up as Status: Tracking Not Installed
.
What am I doing wrong and how do I insert this properly?
According to their instructions - Paste immediately before the </head>
tag:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'XX-XXXXXXXX-X', 'example.com');
ga('send', 'pageview');
</script>
base.html.twig
<head>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'XX-XXXXXXXX-X', 'example.com');
ga('send', 'pageview');
</script>
<meta charset="UTF-8"/>
<title>{% block title %}{% endblock %}</title>
{% block stylesheets %}
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}"/>
</head>
layout.html.twig
{% extends '::base.html.twig'%}
It takes up to 72 hours to detect a newly added tracker. The standard reports can take 24 - 48 hours after that to start registering data. The Real-time reports should show data earlier.
The tracking code you posted looks good, you just need to wait a little until Google picks it up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With