OptiMonk with Google Analytics Tracker or Custom Tag Manager

Currently, it is not possible to enter additional data from the website into OM events.
In additional data sending you'll need custom code e.g.: pageview which requires coding knowledge.

1. Using custom Google Analytics tracker to log pageview.
Please make sure you've inserted the appropriate Tracking ID (UA-xxxxxxx-x)

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
Please make sure you've inserted the appropriate Container ID (GTM-xxxxxx)

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