Add DataLayer Script to my theme to run Dynamic Remarketing Google Ads

Quinnie_Dao
New Member
3 0 0

Hi everyone,

Can you guys please help me. I would like to run Dynamic Remarketing Google ads for my shopify store, but I need to add a script as below:

 

<script>
dataLayer = [];
dataLayer.push({
'event': 'add_to_cart',
'value': 998.55,
'items': [{
'id': 1234,
'google_business_vertical': 'retail'}, {
'id': 45678,
'google_business_vertical': 'retail'}]
});
</script>

 

But before I can add this code to my theme, I need to change the Value, ID to match information with my shopify store. Where can I get this ID code and value? 

I use theme liquid. 

Thanks you.

 

0 Likes
Benoit_Pikka
New Member
2 0 2

Hey ,

I Know it's a bit late to answer this but if anyone needs the info : 

 

<script>
dataLayer = [];
dataLayer.push({
'event': 'add_to_cart',
'value': {{product.price | divided_by: 100.00}},
'items': [{
'id': {{product.id}},
'google_business_vertical': 'retail'}, {
'id': {{product.id}},
'google_business_vertical': 'retail'}]
});
</script>

Jessie77
New Member
2 0 0

Hi Benoit,

Thanks for the code. Would you mind advising me the DataLayer scripts for other event types like product page, begin checkout and purchase?

Thank you very much! 

0 Likes
Benoit_Pikka
New Member
2 0 2

Hi,

Sorry Jessie but I'm not sure wich scripts do you want ? 

You want to send a event in the datalayer when some see a product page ? 

Jessie77
New Member
2 0 0

Hi Benoit,

Yes like the scripts you shared in the message above. If I don't misunderstand, that's for cart page? I'd like to know the scripts for capturing product information (title, price, sku) on each of the product pages & one more subtotal price on the begin checkout page. Also capturing the product info & transaction data on the purchase page.

The optimal result is to create Data Layer variables on GTM through the data passing from the Data Layer scripts.

Any thoughts? 

Thanks,

Jiaxi

0 Likes