Jump to content

How to add Google Tag Manager Snippet Code


kamalglb

Recommended Posts

Hello All,

 

I want to integrate Google analytics with WHMCS. As I need to be able to setup Google Analytics Cross Domain functionality. (My Product website is abc.com and WHMCS is hosted in def.com).

 

So thing is the default google analytics addon won't work here, as the code snippet needs to have auto-linker tag. Also I found the best way to do will be with Google Tag Manager.

 

Now when I try to add the script, which looks something like this:

<!-- Google Tag Manager -->

<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-KLC7XQ"

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-TagID');</script>

<!-- End Google Tag Manager -->

 

To the footer.tpl the buttons on WHMCS pages stop working, and if I add this to header.tpl the page css stops working.

 

Now this is frustrating situation for me, as I want to track actual revenue am generating through my ad campaigns, and that can only be achieved with Google Analytics Ecommerce Tracking, but this way, I can't connect my website with the billing portal.

 

So is there someone who can help me with this, or I will have to find a way to migrate the licenses of my client, as this situation is getting frustrating for me, support is also not helping here.

 

Would really appreciate the suggestion of community members.

Link to comment
Share on other sites

Hello,

 

Although it's mentioned that this is no longer required in newer versions of WHMCS I've found that it is still required for some Javascript code.

 

Try the following:

 

<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-KLC7XQ"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
{literal}
<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-TagID');</script>
{/literal}
<!-- End Google Tag Manager -->

 

Regards,

Jack

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated