Google Ads Add to Cart Tracking (manuall Code)

Hello,

can anyone tell me how i can track add to cart’s with google ads?

I dont want to use google analytics, i created the code and know that i need to place it in the cart liquid file but i dont know the dynamic value parameter to track the value of the add to cart.

Can anyone give me a example code?

Thanks!

Hi @x264

Can you post the snippet you’ve been asked to add, removing any ID’s relevant to your Google Ads account.

It’ll depend on what version you’re using I believe. It’d be easier to see what you’re being asked to look at.

You should be able to pull the dynamic values from either Liquid or in the Click event using vanilla js or the Ajax API.

Thanks

1 Like

Just the normal event snippet, i just want to know the dynamic value parameter for shopify to track the cart value.

Hi @x264

The snippet here is add to cart - but will fire every time someone visits the page, it’s not called dynamically.

Therefore what you’ll want to do is run this code when an add to cart button is clicked, not just on page load.

That’s almost a separate discussion on setting that up, but using the liquid values it’d look something like:

{% assign current_variant = product.selected_or_first_available_variant %}
{% assign current_variant_price = current_variant.price %}

That’s with very little research into the setup of your site.

You’ll need to consider the order in which events are firing and probably do some error handing in the JS etc.

But that’s the initial idea for using Liquid variables as dynamic values in that script.