Click to call

Ask any web marketer what their biggest challenge is, and I would wager that the most common thing you would hear is “tracking ROI”.

Unless you’re in ecommerce, where the entire customer experience happens online and can be tracked with relative ease from start to finish, most customer lifecycles have offline components to them – whether it’s someone calling up your sales line or coming in to your store. While these offline events are extremely important to your business (for many businesses, they are your business – for instance physical stores or businesses that primarily sell over the phone), unfortunately people don’t wear a sign around their neck with the Google Analytics user ID (that would be really useful though).

This means that for all the hard work you put in doing kick-ass SEO campaigns, community management and email marketing – if someone picks up the phone to buy or comes in to your store, you have virtually no way of attributing that sale to what marketing efforts actually bought them there.

All solutions to this problem are imperfect. Call tracking software is a headache nearly every way you slice it. Sure it’s great to know how many phone calls are coming from your Adwords campaigns, but unless you buy a crap-ton (technical term) of phone numbers, you don’t know what ad groups or keywords are driving business. Then there’s the problem of tracking numbers ending up saved in peoples phone, further blurring your data. Then what about organic visits?

Google’s new Universal Analytics is a great step in the right direction, giving us the ability to leverage an API to record things that happen away from the website. But it is still dependent on knowing a person’s user ID where ever they are. Forget the old analytics problems of “what if people clear their cookies?”. What about multiple browsers? Multiple devices? Add to that phone calls and in-person interactions and you have a myriad of circumstances where the best technology in the world won’t tell you the value of that cookie that was placed on their browser the first time they visited your site.

Incentivizing log-ins will be one way marketers will try to close the loop – and allowing log in with things like Facebook or Open ID certainly make that easier. But I’m not going to log into a restaurants website to find out when their open hours are. I’m not going to authorize Facebook access for my local plumbing company when there’s s*#t overflowing out of my toilet. So how are these businesses suppose to track their marketing efforts?

How do you get to that magical ROI number?

The answer, I believe, isn’t in the transaction – it’s in the followup. These days web technology is all about real-time. Everything has an API that integrates with everything else. But sometimes you don’t actually need to know when something happens – you just need to know that it happened at all.

After-purchase follow-up is incredibly important, both for overall customer satisfaction and for the potential for future business. Email newsletters, special offers, even the way you send the receipt are the next step of an on-going and hopefully long-term relationship.

So if you have a list of people who you know have bought from you, and we communicate with them, is there a way we can get them back to website and trigger a conversion now. With any luck, they’ll still have the original GA cookie that they got when they first visited your website – and bam! Conversion with attribution.

Well – there is – and I have. Huzzar!


First off, a disclaimer. I AM NOT A DEVELOPER. I went to business school. Everything I know I’ve learned about code has been on-the-job and generally out of some small-company-there-is-no-one-else-to-do-this necessity.

However, I’ve tinkered enough with WordPress sites that I can generally figure out what I want to do through a long process of Google -> Copy -> Paste -> “Why the F*#k isn’t this working?!” -> Google -> Remove the Goddamned period that’s breaking my code -> Success!

The idea of trigger.js is pretty simple. Use innocuous URL parameters that could be added to any URL emailed to a customer – a newsletter, an offer, a receipt – and use that to trigger a Google Analytics event that we could use for goal tracking. A simple /?c=1 would trigger a predefined event (for instance “purchase”), which could then be set up as a goal conversion within Google Analytics.

I first wrote this in PHP for an existing client, which I’m far more comfortable with. It was all working great on the staging server, but stopped working completely when I pushed to live. This is when I figured out that the downside of using WP Engine’s kick-ass WordPress hosting is that everything is cached up the wazuu! The script was never running. So I rewrote it using jQuery.

It’s not perfect and I’m sure the developers out there will be disgusted with my poor code (any offers to rewrite this would be graciously accepted), but it works. Here’s how:

The Tracking Process

This script was built to do more than just track conversions, but also track the micro-conversions of becoming a “lead” (a submission of some information to the website) and a “qualified lead” (i.e. some interaction with the company proving the submission was genuine).

This means that we needed some logic within how the script worked – a lead can become a qualified lead, and a qualified lead can become a customer – but a customer can’t revert to being a “lead” again (at least for this model of trying to track initial purchase attribution). That means the script is going to have to cookie the user with a status tag.

Also, since we’re using Google Analytics events,  we will only want to track a single conversion for each person – even if they click on a link multiple times. Therefore, a conversion will only happen a) if the parameter denotes a higher level status tag than the users cookied status and b) if this is the first time the link is clicked/visited.


The perfect scenario is that we track someone becoming a lead, a qualified lead and then purchasing, however, the script will allow someone to jump straight to “qualified lead” or “purchase”. Even if you send an email to every person who goes through every stage of the process – not everyone is going to click on every link you send them. Then there are the people who jump steps in the process, for instance the person who comes to your website, then calls you up and buys (jumping straight to purchase).



In addition to a status tag, the script can also pass through a value for “medium”, or how the customer contacted you, phone, email, website or SEM, as well as a value parameter which could be used to pass the customers dollar amount value into Google Analytics as well.


[table id=1 /]


Important Note: While I think Universal Analytics is awesome, it’s not currently widely used enough to make it viable to build this script specifically for it – instead it’s designed for ga.js – primarily because that was what I knew. UA handles event tracking slightly differently. If anyone wants to rewrite the script to work for UA or even better, make it agnostic to GA version, awesome! Post a comment below.

The script creates the following GA events, all under the event category “Customer”.

Action = lead, qualified lead and purchase

Label = medium

Value = value

I recommend setting up a Google Analytics goal for each (lead, qualified and purchase). Set the goal based on event and set Category to “Customer” and Action to “lead”, “qualified” or “purchase” depending on the goal you’re setting up.


Installing the Script:

Installing the script is pretty easy.

Download trigger.js here.

Just upload it to your website and place the following in the footer. (Your Google Analytics script should be in the header, but in case it’s not for some reason, make sure this script comes after it).

<script src="./trigger.js"></script>


Make sure you change the source if you upload it in a different place than your site files.

For WordPress, I put it my theme and called it in footer.php with this:

<script src="<?php echo get_template_directory_uri() ?>/lib/scripts/trigger.js"></script>

So that’s it. It’s only a first version and I think there’s a lot of potential for it to expand. Universal Analytics is going to massively expand how we can track events in the real world through the Google Analytics interface we know and love, however it’s going to be within the business processes and logic that we actually find the solutions.


Prefer Email? Say Hello!
[email protected]
Talk With Us!
Book a Meeting!

Please use the calendar to the right to book an initial meeting with our sales team.

Fill Out the Form Below!

Have a specific service in mind or looking to share more about your project goals? Fill out the form on this page and one of our sales specialist will get back to you ASAP.