Shopify is a popular e-commerce platform that allows users to set up their online store and start selling products. As an online store owner, it is essential to track user interactions on your website to gain insights into customer behavior and optimize your sales funnel. One of the most critical metrics in e-commerce is the “Add to Cart” button click. In this blog, we will discuss how to track Shopify “Add to Cart” clicks with Google Analytics and Google Tag Manager.
Setting up Google Analytics
To track user behavior on your website, you need to set up Google Analytics. If you haven’t already, create a Google Analytics account and link it to your Shopify store. Once you have linked your account, navigate to the “Admin” section of Google Analytics and create a new “Goal.”
Creating a Goal
A goal in Google Analytics is a specific user interaction you want to track. In this case, we want to track “Add to Cart” button clicks. To create a goal, follow these steps:
- Go to the “Admin” section of Google Analytics and click on “Goals.”
- Click on the “+New Goal” button.
- Choose the “Custom” goal type and click “Continue.”
- Name your goal and choose “Event” as the goal type.
- In the goal details, set the “Category” to “Button.”
- Set the “Action” to “Add to Cart.”
- Leave the “Label” and “Value” fields blank.
- Click “Save” to create the goal.
Installing Google Tag Manager
Google Tag Manager (GTM) is a tool that allows you to manage and deploy tracking codes on your website. To install GTM on your Shopify store, follow these steps:
- Create a GTM account and container.
- Copy the GTM container code.
- Log in to your Shopify store, go to “Online Store,” and click on “Themes.”
- Click on the “Actions” dropdown and select “Edit Code.”
- Paste the GTM container code in the head section of your theme’s layout file (theme.liquid).
- Save the file and publish the changes.
Creating a Trigger
A trigger in GTM is a specific user action that activates a tag. In this case, we want to create a trigger that fires when a user clicks the “Add to Cart” button. To create a trigger, follow these steps:
- Go to your GTM container and click on “Triggers.”
- Click on the “+New” button to create a new trigger.
- Choose “Click” as the trigger type.
- Select the “Just Links” option.
- Set the “Click URL” as “{{Click URL}}”.
- Set the “Click ID” as “add-to-cart”.
- Save the trigger.
Creating a Tag
A tag in GTM is a code snippet that tracks user behavior on your website. In this case, we want to create a tag that sends an event to Google Analytics when a user clicks the “Add to Cart” button. To create a tag, follow these steps:
- Go to your GTM container and click on “Tags.”
- Click on the “+New” button to create a new tag.
- Choose “Google Analytics – Universal Analytics” as the tag type.
- Set the “Track Type” as “Event.”
- Set the “Category” as “Button.”
- Set the “Action” as “Add to Cart.”
- Leave the “Label” and “Value” fields blank.
- Under “Google Analytics Settings,” select the appropriate Google Analytics variable.
- Under “Triggering,” select the trigger you created in Section 4.
- Save the tag.
Testing and Publishing
Once you have created the tag, you can test it by going to your Shopify store and clicking the “Add to Cart” button. You should see the event being sent to Google Analytics in real-time.
After testing, you need to publish the changes in GTM to your Shopify store. To publish the changes, follow these steps:
- Go to your GTM container and click on “Submit.”
- Add a version name and description for the changes you made.
- Click on “Publish” to publish the changes.
Once the changes are published, you can view the “Add to Cart” button click events in your Google Analytics reports under the goal you created in Section 2.
Conclusion
Tracking user behavior on your Shopify store is essential to optimizing your sales funnel and increasing conversions. By tracking “Add to Cart” button clicks with Google Analytics and Google Tag Manager, you can gain valuable insights into user behavior and make data-driven decisions to improve your e-commerce store. Follow the steps outlined in this blog to start tracking “Add to Cart” button clicks today.