Tracking with Google Tag Manager using Custom Javascript

Overview

Floify's custom JavaScript feature allows you to integrate Google Tag Manager (GTM), tracking events, links, and more within Floify, reporting them back to GTM for analysis.

This guide assumes you have already enabled and configured GTM. For more information on GTM setup, see Google's documentation here.

 

 

How to Set Up

Find your GTM installation instructions in Google. This page will show some code for you to copy + paste:

 

 

 

 

In Floify, on the Company Dashboard, navigate to Company Settings > Developer > Company Custom CSS/JS and select Edit Company Custom Code:

 

 

 

 

Copy your GTM code and paste it in the Floify code editor. There should be two separate sections, which can be placed contiguously within the editor. Below that, you'll add some code that invokes GTM and generates an event. For example, in this case, the script checks the page URL for a referer, and sends that to GTM in a "floifyLoaded' event:

 

<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=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','MY-ID');</script>

<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=MY-ID"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
const params = new URLSearchParams(window.location.search);
const floifyReferer = params.get('floifyReferer');
console.log('floifyReferer: ' + floifyReferer);
gtag('event', 'floifyLoaded', {
'floifyReferer': floifyReferer
});
</script>

 


 

 

Once that's in place, Floify will send an event to your GTM every time a Floify page loads. Here we can see an example of how that data looks in GTM:

 

 

 

 

That's it! Now you can adapt the GTM code in Floify as needed to produce the specific tracking events you're looking for. 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Article is closed for comments.