Tag Archives: script

Two Shopify Theme Edits to Improve Your Tracking

So, you’ve gone and gotten yourself a Shopify store. Congratulations! They’re an excellent platform that helps people build successful online stores. (And I’m not just saying that because I wrote for them before!)

But there’s two things it doesn’t do out of the box:

  1. Give you a unique URL to track new account creations.
  2. Give you a way to track outbound clicks.

This is amazingly easy to fix.

Track New Account Creations

Go to Themes > Edit HTML/CSS > customers/register.liquid. Edit HTML/CSS is under the … menu at the top.

2016-09-18_19-09-28

You need to add one line to your customer form.

      <input type="hidden" name="return_to" value="account/?acct=new" />

2016-09-18_19-05-09

You can change that ?acct=new to whatever you want. But by adding a parameter to the end of the URL people are directed to after signup, you can then create a Goal specifically for visitors to /account/?acct=new like this:

2016-09-18_19-14-29

Regular logins won’t go to that URL, just people filling out the account creation form.

Hat tip to Shopify customer forums user Caroline Schnapp for this solution, originally found in this thread.

Tracking Outbound Links

Tracking outbound links can be a great way to see who’s getting to your social media from your storefront, or any other outside links you might have.

Sivakumar at EcommPPC has a script snippet that solves this. (Note: This is for Universal Analytics. If you’re still using the old version for some reason…. UPGRADE.)

<script>
$(document).ready(function(){
 var localserver = "mysite.com";
 $("a").not("a[href^='http://"+localserver+"']").not("a[href^='https://"+localserver+"']").click(function(){
 $(this).attr("target", "blank");
 ga('send', 'event', 'links', 'click', $(this).attr('href'));
 });
});
</script>

I’m reposting the script here to provide a version that doesn’t have curly/fancy quotes.

Change “mysite.com” in the above script to the primary domain of your store. (Not the full URL with http, just the domain name.)

Add the script just after the opening <body> tag. Now links to other websites posted anywhere on your Shopify store will be tracked as Events in Google Analytics. This script will tag them all as Category “links” and Action “click”. The label will be the full URL the visitor clicked.  I might recommend changing “links” to “Outbound Links” or just Outbound, to make sure your event category is as clear as possible.

I used this recently to track clicks to a booking page on Calendly.

2016-09-18_19-25-01

 

So that’s it! Two ways to quickly and vastly improve your tracking when using Shopify!