Jump to content

Google Tag Manager 4


Recommended Posts

In case anyone wants to dive headlong into GTM 4 (as this doesn't support anything earlier), check out our module on GitHub: https://github.com/websavers/WHMCS-Google-Tag-Manager

As a developer GTM 4 is fantastic as the API for building events no longer feels like 7 different APIs hacked together with duplicate data everywhere. Granted its front end reporting tools can sometimes feel a bit weaker than the former enhanced analytics.

Open to pull requests.

Link to comment
Share on other sites

  • 1 year later...

This is exactly what was looking for!¬† I wasn't getting the view_item, etc to fire with the basic WHCMS setup. ūüė쬆

But the add_to_cart doesn't seem to fire, I don't get any hits on that one.   I'm using the Lagom theme V2.1.2

Thanks!

Link to comment
Share on other sites

Hey @FutureX

I took a look at the demo for the theme here: https://demo.rsstudio.net/lagom/cart.php?a=add&domain=register&rspage=default

Since it doesn't utilize an actual cart page, there's no way for the add to cart event to be triggered. Rather than a separate cart page, it immediately begins checkout with a cart review at the top of the checkout page, so that means add_to_cart would be one and the same with begin_checkout.

If you'd prefer it track checkout as an add_to_cart event, I'm afraid you'll need to modify the code found here: https://github.com/websavers/WHMCS-Google-Tag-Manager/blob/main/modules/addons/google_tag_manager/hooks.php

Under the viewcart  case on line 173, remove everything before the break; except these two lines:

        $event = 'add_to_cart';
        $action = 'viewcart';

That should then track begin_checkout events as add_to_cart events instead.

Link to comment
Share on other sites

OK great, so I've modified it to this:

case 'viewcart':

        $event = 'add_to_cart';
        $action = 'viewcart';
     
      break;

 

Just tested it and it works! 

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

I'm afraid I have no idea why that would be the case; you'll need to troubleshoot the code to find out; try putting a bunch of logActivity() calls with the data you want to find out about in relevant points in the code and see what you can find.

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