OptiMonk with custom Google Analytics tracker or custom Tag Manager datalayer.

1. Using custom Google Analytics tracker

This is an example of a default Google Analytics tracker code:

<script type="text/javascript">
    (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-80608409-1', 'auto');
    ga('send', 'pageview');
</script>

This is an example of a custom Google Analytics tracker code ('gaTracker','tracker1'):

<script type="text/javascript">
    (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','gaTracker');

    gaTracker('create', 'UA-80608409-1', 'auto', 'tracker1');
    gaTracker('tracker1.send', 'pageview');
</script>

In case you have a custom Google Analytics tracker code you need to insert the following code snippet right after the OptiMonk JavaScript code:

<script type="text/javascript">
    var OptiMonk = {
	 config: {
	   analytics: {
		 varName: 'gaTracker',
		 trackerName: 'tracker1'
	   }
	 }
	};
</script>

2. Using custom Tag Manager datalayer

This is an example of a default Tag Manager code:

 <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-5L48H3"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5L48H3');</script>

This is a Tag Manager code with custom datalayer ('randomLayer'):

 <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-5L48H3"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='randomLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','randomLayer','GTM-5L48H3');</script>

In case you have a custom Tag Manager code you need to insert the following code snippet right after the OptiMonk JavaScript code:

<script type="text/javascript">
    var OptiMonk = {
	 config: {
	   tagManager: {
		 varName: 'randomLayer'
	   }
	 }
	};
</script>

Have more questions? Submit a request

Comments