Trouble running Optimize tests

Created by Mohammad Siddiqui, Modified on Wed, 5 Jun, 2019 at 10:32 AM by Mohammad Siddiqui

If you just activated Optimize 360 and keep getting the “analytics pageview not detected” error like the one below:





The problem maybe that the Google Analytics code on the site is misconfigured.  The pageview is actually *not* firing.

If this is how your current code looks like:

<!-- Google Analytics -->
<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', 'UA-37934458-1', 'auto', { 'sampleRate': 5 } );
ga('require', 'GTM-WJGRMKT'); // Optimise Installation
ga('linker:autoLink', ['globalnews.ca']);
ga('set', 'dimension1', "ottawa"); // User Region
ga('set', 'dimension2', "national"); // Content Region
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

it maybe missing a REQUIRE call for the linker plugin being used at ga('linker:autoLink', ['globalnews.ca']);

To fix this, we need to add a line as follows:

<!-- Google Analytics -->
<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', 'UA-37934458-1', 'auto', { 'sampleRate': 5 } );
ga('require', 'GTM-WJGRMKT'); // Optimise Installation
// Loads the Linker plugin
ga('require', 'linker');

ga('linker:autoLink', ['globalnews.ca']);
ga('set', 'dimension1', "ottawa"); // User Region
ga('set', 'dimension2', "national"); // Content Region
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article