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.
- How can I dynamically fetch the price and product id i.e. in place of replace with value below?
- Is there any variable for the same?
- 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>
Tags:
5 comments
Hi Bhavya,
Did you ever figure out how to do this?
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.
Thanks JeffreyS
Got it working? @davep
@JeffreyS Yes, got it working, but had to use {{ product.id }} instead of {{ product.sku }} to match the product feed. Thanks again.