Optimize
3.3K members online now
3.3K members online now
Learn how to create your first experiment and get tips on creating A/B, redirect, and multivariate tests.
Guide Me
star_border
Reply

How do I change the woocommerce Google Analytics pro tracking code to use Google Optimize?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I am using the Woocommerce Google Analytics Pro plugin and managed to change the tracking code on each page as follows:

 

<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','https://www.google-analytics.com/analytics.js','ga');
	ga( 'create', 'UA-XXXXXX-X', 'auto' , {'siteSpeedSampleRate': 100});
	ga( 'require', 'GTM-XXXXXX');
	ga( 'set', 'forceSSL', true );
	ga( 'require', 'ec' );</script>

 

But I get no results in Google Optimize. What could be the problem? Do I need to add?:

ga('send', 'pageview');

 Hope anyone can help.

How do I change the woocommerce Google Analytics pro tracking code to use Google Optimize?

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

Hi,

I just figured out how to do it. 

Open the "class-w-google-analytics-pro-integration.php" file

look for "<?php echo $this->get_ga_function_name(); ?>( 'create', '<?php echo esc_js( $this->get_tracking_id() ); ?>', 'auto' );

Right underneath that paste your optimize google code.

Optimize google is working now without problems.

 

Cheers,