Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2009
    Posts
    43
    Plugin Contributions
    0

    help question Google Ads Remarketing in 2019 with dataLayer and ZC 1.5.5

    Hi all,

    I'm supporting www.premierrange.co.uk where we run a heavily modified ZC 1.5.5 with mods like CEON URI Mapping, password verification on signup etc. Our own modifications are probably far more significant than the changes made by these mods.

    My question is about how to integrate the Google Ads Remarketing Tag with the way Zen Cart builds its pages, specifically the flow from html_header, to main_template_vars, to the product page etc. and what is known at each point in time.

    For some years we've been using Google Remarketing which involves us calling a Javascript 'gtag' function, passing in some data about the event, the product SKU, price, GTIN, etc. I believe this used to be a simple javascript function that immediately (or shortly after) made an XHR call to Google to pass over the data. This was a simple case of loading the library via a '<script>' tag in html_header in the '<head>' and later calling gtag() from any javascript block.

    Recently they seem to have re-implemented their library and are advising people to not use 'gtag' and more, but instead use some kind of 'dataLayer' variable, which seems to be a simple array. There is a migration guide at https://support.google.com/google-ad..._topic=3122875 where you can see the 'Event Snippet' shows the old fashioned call we would make:

    gtag('event', 'add_to_cart', { .. lots of data .. });

    Just below there you'll see the code that allows the new 'dataLayer' array to be used via the same gtag() calling mechanism:

    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}

    So now the 'gtag' function simply pushes onto an array called dataLayer.

    Google says that you must push data onto the dataLayer _before_ loading the remarketing library, which means it has to be done while '<head>' is being generated and before the script tag for the library is output. From the look of the code, unless they are overloading the Array.push prototype to do something clever, I can see that simply pushing onto the array isn't going to achieve any code execution. So, if we declare dataLayer and load the remarketing library in html_header.php (or somewhere similarly early in page execution to be within '<head>') then pushing onto dataLayer some time later, for example during tpl_product_default.php, it's not going to be sent to Google.

    While ZC is outputting a product page, it seems the first time the products_id query parameter is used to retrieve any useful information about the product being viewed is in the main_template_vars.php script of the product page, which is after the '<body>' of the page has been output, it's far too late then to start pushing onto dataLayer.

    Has anyone else experience of the recent changes to the Google Remarketing library and can comment on how to weave it into Zen Cart?

    It looks like I'm going to have to move, or duplicate, some of our fairly complex logic from main_template_vars where the system figures out which product is being requested, its price and so on, into html_header so that I can push onto dataLayer, but I don't like hacking ZC for the sake of Google's changed implementation.

    Just some background, we implement a 'variations' system a bit like eBay's variations, where a single Zen Cart product represents tens or hundreds of physical products, so the products_id is constant but some other query parameters indicate the exact product that is being viewed or ordered, it works with the ZC 'attributes' system to apply attribute values like Colour, Size etc that result in different SKUs and GTINs for the product being ordered. This is the lookup that's done in main_template_vars.php for our custom product, which is too late to pass to Google's Remarketing Library.

    Sorry for the rant :) Not sure if this belongs in the 'Search Engines' forum. Any advice appreciated before I bite off more of this work :)

    Nick

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    9,036
    Plugin Contributions
    72

    Default Re: Google Ads Remarketing in 2019 with dataLayer and ZC 1.5.5

    You might take a look at how the Super Data Markup plugin (https://www.zen-cart.com/downloads.php?do=file&id=1984) deals with that chicken/egg situation you've described.

    Essentially, there's an additional module loaded by a site's active template's html_header.php to pull in the database values to allow that data being populated in a page's <head>.

  3. #3
    Join Date
    Feb 2009
    Posts
    43
    Plugin Contributions
    0

    Default Re: Google Ads Remarketing in 2019 with dataLayer and ZC 1.5.5

    Thank you @lat9 :) I'll check it out, sounds very relevant to my situation, and in line with my guess that you basically have to fetch data earlier in the page load cycle than zen cart normally does so as to satisfy these requirements.

    It does seem like a chicken/egg situation, and quite a frustrating one given Google's support on the matter. I spent 2 hours on screen share with one of their engineers, who was very well meaning but seemed to be reading off a script, and was very reluctant to say she didn't know something. In the end I had to presume that the Google remarketing library works in one way, and zen cart's page generation mechanism works in another way, and it's not her problem that they aren't compatible, so I tried to be very nice to her about it.

    I empathise with her position, I spent some months on a support contract for a large IT project, and we were rarely very well informed, didn't have access to the source code or actual algorithms being employed, and honestly that was the job that drove me to become self employed and take some control of my destiny.. so, a win, overall :)

  4. #4
    Join Date
    Jan 2015
    Posts
    216
    Plugin Contributions
    0

    Default Re: Google Ads Remarketing in 2019 with dataLayer and ZC 1.5.5

    neekfenwick,

    You may want to take a look at
    https://www.zen-cart.com/showthread....le+remarketing

    Starting on Post #115. I believe this should help you solve your issue,

 

 

Similar Threads

  1. 1.39h google dynamic remarketing
    By tbaquatics in forum General Questions
    Replies: 5
    Last Post: 2 Jul 2018, 07:13 PM
  2. v151 Problems with Google Dynamic Remarketing Mod: ecomm_prodid
    By alray10 in forum All Other Contributions/Addons
    Replies: 18
    Last Post: 2 Jul 2018, 06:09 PM
  3. v151 google remarketing code
    By stickleback in forum General Questions
    Replies: 3
    Last Post: 8 Oct 2012, 05:41 PM
  4. v139h Placing Google Adwords Remarketing Code On Specific Pages
    By emovendo in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 31 Jul 2012, 12:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR