How To Track New Customer Acquisition in Google Analytics With Shopify

For any business, the value of a customer extends beyond the immediate dollar value of their purchase. Rather, the value of a customer is equal to the present value of their future purchases, as well as the cost savings that often accrue as a result of reduced marketing expenses (think e-mail marketing vs. the Google Ads auction) 📈. Understanding the value of a new customer is therefore critical when it comes to making informed marketing decisions.

Equally important is understanding where new customers come from i.e. which marketing channels are best at generating new customers. While Google Analytics provides some insight into new vs. returning customers, the data is not very reliable given the way in which it is collected 👎.

Fortunately for Shopify users, there is a very simple way to accurately track new customers in Google Analytics, thanks to the customer object which Shopify exposes 🎉. More specifically, the customer.orders_count value allows us to see how many orders a user has placed (a user being defined as a unique e-mail address).

With this information, we can add some very simple Google Analytics event tracking code* to the checkout page that allows us to track new customer🤓:

{% if first_time_accessed %}
window.onload = function() {
var orders = {{ customer.orders_count }};
if(orders === 1) {
ga('send', 'event', "New Customer", "Making it Rain"); 
{% endif %}

The logic is pretty straightforward: we check to see how many orders are associated with the user and, if this is their first order, we fire off the event tracking snippet 👨‍💻.

Having installed the above code we can then see which channels are generating new customers:

In addition, we can create a goal in Google Analytics and assign a value to new customers. This goal can then be imported into your Google Ads account, allowing you to give additional value to those campaigns that are helping generate new customers 💰.

*Consult a developer or Shopify expert before adding any code to your checkout page.

Lars Larsen
Head of Google Ads & Partner