Checkout Toolbox

Flex Theme Sections

Linear Shopping Experiences

GA4 and your Shopify Store

About GA4

As you may know, Google Analytics is ending support for its Universal Analytics (UA) next July.  It will be replaced by GA4.  Currently, Shopify supports UA and that's what you have in your store if I've worked on it. And Shopify is working on building native support for GA4, but they do not have a date for it yet.

But here's the catch, GA4 will not use UA data.  So, if you want to see year-over-year metrics in your store next year, you need to add GA4 tracking to your site now.  I would say this is important if you use Google Analytics data. 

Setup Steps

Here's the steps for adding basic GA4 tracking to your store:

  1. Open Google Analytics
  2. Go to Admin (lower left gear icon)
  3. Under Property, see if GA4 property already exists
  4. If not, under the desired UA property, select GA4 Setup Assistant
  5. Click the Get Started button
  6. Then click the Create Property button
  7. Then click the Go to your GA4 property button
  8. Go to Data Streams
  9. Click the > under View tag instructions
  10. Click Install manually
  11. Add the tracking snippet to theme.liquid right under <head>
  12. Test that tracking is working in GA real-time report (may take a couple of minutes for the first data to show)
  13. Go to Data Streams > Configure tag settings > Configure your domains and add these domains with the Contains match type:
    1. URL for the site
    2. url for the site
    7. Any urls for other 3rd party payments like
  14. Add the snippet below in the Shopify admin under Settings > Checkout > Order status page.

Code for Shopify Theme

Code snippet for order confirmation page.  Replace STREAMID with your numerical Stream ID in two places.

<!-- Global site tag (gtag.js) - Google Analytics -->
<script type="rocketlazyloadscript" async src=""></script>
<script type="rocketlazyloadscript">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'STREAMID');
{% if first_time_accessed %}
gtag("event", "purchase", {
transaction_id: "{{ order.order_number }}",
value: {{ total_price | times: 0.01 }},
tax: {{ tax_price | times: 0.01 }},
shipping: {{ shipping_price | times: 0.01 }},
currency: "{{ order.currency }}",
items: [
{% for line_item in line_items %} {
item_id: "{{ line_item.product_id }}",
item_name: "{{ line_item.title | remove: "'" | remove: '"' }}",
currency: "{{ order.currency }}",
price: {{ line_item.original_price | times: 0.01 }},
quantity: {{ line_item.quantity }}
{% endfor %}
{% endif %}


JadePuma is a certified Shopify Expert. If you need any help with your Shopify store, we can help.