Google Dynamic Remarketing Code

Hello,


I have a webshop with more than 30,000 products. I want to start the google dynamic remarketing i.e. show the ad with the product that a user visited in my shop but did not checkout. To do so, I need to add the below Event snippet in all the product pages.

  1. How can I dynamically fetch the price and product id i.e. in place of replace with value below?
  2. Is there any variable for the same? 
  3. Also, in order to place it in all the products page, where exactly should this be placed in the template?

<script>

 gtag('event', 'page_view', {

  'send_to': 'AW-XXXXXXXX',

  'value': 'replace with value',

  'items': [{

   'id': 'replace with value',

   'google_business_vertical': 'retail'

  }]

 });

</script>

5 comments

  • davepdavep Member Posts: 6

    Hi Bhavya,

    Did you ever figure out how to do this?

  • JeffreySJeffreyS Member Posts: 14
    edited December 2021

    You can do this by adding the script to the product.rain template-file in the theme editor, if you don't have an option integrated in the theme for this (some offer this built-in).

    Try this:

    <script>

     gtag('event', 'page_view', {

      'send_to': 'AW-XXXXXX',

      'value': '{{ product.price.price }}',

      'items': [{

       'id': '{{ product.sku }}',

       'google_business_vertical': 'retail',

      }]

     });

    </script>

    I'm using the sku/mpn and map this in Google Merchant Center to id, a feed-setting. But you can use the internal Lightspeed ID too, whatever suits your need. In that case you have to replace {{ product.sku }} with a different variable, for example {{ product.id }}.

    You can find more information about the available variables at the following page (see the product.rain section): https://ecom-support.lightspeedhq.com/hc/en-us/articles/115000277594-3-b-Rain-variables

    Please do note, this is only the solution for a productpage. There are possibilities for "add to cart", catalog/category pages, and so on.

  • davepdavep Member Posts: 6

    Thanks JeffreyS

  • JeffreySJeffreyS Member Posts: 14

    Got it working? @davep

  • davepdavep Member Posts: 6

    @JeffreyS Yes, got it working, but had to use {{ product.id }} instead of {{ product.sku }} to match the product feed. Thanks again.

Sign In or Register to comment.