FROM CACHE - en_header

How to Track "new customers" separately with new GTAG tracking

RaoulvanH
New Member
1 0 1

Hi,

for a few clients we're keen on updating their existing Google Ads tracking with an extra parameter to separate "new customers"  from existing ones. I understand we need to update the checkout GTAG with one line of code, but obviously, we need to have a variable that triggers the right boolean value.

https://support.google.com/google-ads/answer/9918441?hl=en#:~:text=Getting%20started%20in%20Google%2...

1) is this possible ?

2) if yes, how would you upgrade the existing GTAG implementation:

<!-- Global Site Tag (gtag.js) - Google AdWords: xxxxxx -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-xxxxx"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'AW-xxxxx', {'send_page_view': false});
</script>

{% if first_time_accessed %}
<script>
 gtag('event', 'conversion', {
     'send_to': 'AW-xxxx/xxxx',
     'value': {{ checkout.subtotal_price | money_without_currency }},
     'currency': '{{ shop.currency }}',
     'transaction_id': '{{ order_number  }}'
 });
</script>
{% endif %}


Thanks a lot for your input!

 

Reply 1 (1)
Bogdan4
Shopify Partner
2 0 0

I'm also searching for a solution to this. The biggest challenge would be determining when an order is from a first time customer or not. Google requires the following output for the new_customer parameter:

  • true, when the order is from a first time customer
  • false, when it's a repeat customer
  • 'unknown', when the customer type can't be determined

In the docs about liquid I found 2 properties that might be useful to make the determination: `customer.orders_count` and `customer.has_account`. It would be something like:

if customer.orders_count > 0
then set 'false'
else set 'true'

 

I'm not sure that would cover all scenarios and I'm not a coder, so my code above is 100% incorrect, but maybe someone with more experience can chime in