I’ve been teaching myself JavaScript in the last few weeks to up my GTM implementation skills, so I thought I’d share some examples of how I’ve used it.

This one is for pulling out the sub-directory from the URL to use in an event. This came in handy for me when implementing Mixpanel a couple months ago for a client, and is especially helpful for sites that have a solid directory structure. For instance, the shoes page on an eCommerce clothing site might look something like this:


If you want to create an event for all of the category pages, it’s helpful to be able to pull out “sneakers” and use it in a property so that you can compare it to events with the property of “dress-shoes” and “sandals”.

I created a Custom JavaScript variable in GTM and here’s the code I used:

function () {
 var value={{Page Path}}.split("/");
 return value[1];

This pulls out the 2nd sub-directory (‘shoes’ in this case) and stores it in a GTM variable. You can change which directory level gets pulled by changing the [1] to [0] or [2] or whatever (the counting always starts with 0).

Here’s a screen shot of the custom variable in GTM:



I read this on Seth Godin’s blog a couple years ago and I think it fits nicely with last month’s post on the What, How, Why approach to analytics:

Without a doubt, the ability to connect the dots is rare, prized and valuable. Connecting dots, solving the problem that hasn’t been solved before, seeing the pattern before it is made obvious, is more essential than ever before.

Why then, do we spend so much time collecting dots instead? More facts, more tests, more need for data, even when we have no clue (and no practice) in doing anything with it.

Their big bag of dots isn’t worth nearly as much as your handful of insight, is it?

Data forms many dots. Dots are agnostic. They exist, they’re phenomena, but they don’t really have meaning. Only when subjectively interpreted by a human, do they acquire meaning.

If you’re not connecting them in a meaningful way, a way that’s meaningful for your business or your client or your boss or your health, or whatever you’re trying to understand and improve, then you’re not really doing anything.

There’s a kind of resistance in analytics that comes in the form of the voice in your head that says “we just need to get all our tracking set up perfectly, and THEN we can start doing something with the data.” Yeah, I know from experience. It’s something I have to fight in myself too.

But what if you were only allowed to use one tool or even one metric? If I gave you $10,000, do you think you could find some meaning, some improvement, some insight with that one tool or metric? Probably. And you probably have more than one tool working already, so really it’s just resistance that’s keeping you from doing something important with them.


This is a simple way to model your thinking about how to approach a website and breathe life into your analytics numbers. It’s how I approach things and I don’t think it’s terribly original, but I wanted to clarify my thinking on my approach, so here we are.

Let’s say we’re looking at the homepage of a site.

The What: Analytics and Clickstream Data

The ‘what’ consists of the clickstream data around the homepage: visits, uniques, pages per visit, time on page, time on site for visitors who landed there, bounce rate, conversion rate. There are more but those are the ones we usually look at.

We have this data for all the pages on our site, but it doesn’t usually come into play until there’s a problem. Once there’s a problem, usually in the form of someone asking “how come are sales aren’t higher?” and so you look and maybe see that the bounce rate is really high for the homepage and so hmm that’s not good, is it?

You dig deeper and see that 80% of traffic is entering the site through the homepage and that the bounce rate for the homepage is 70%. Ouch. Track down the designer and publicly shame them. Kidding. A better idea would be to go ask the designer for the research they conducted during the design process. If you get a blank stare, then great, you’re going to earn your money.

OK, back to the what. So the analytics data you have will tell you what is going on. People are entering, seeing the homepage, and then leaving. Side note: if you’re using Google Tag Manager, then I recommend setting up an event timer listener so you know if they’re actually just bouncing right away or if they’re sticking around for a bit.

Now, at this point, you can go back to your client and tell them that their bounce rate is high, which will be of zero value to them since you don’t have a solution to address the problem. Besides, if they pissed away paid thousands of dollars for the design, they have a vested interest in being right about that decision and you’ll be fighting upstream psychologically-speaking, which it’s tough enough to change a homepage as it is (or you’ll be fighting the IKEA effect if they built it themselves, which made me laugh when I discovered that there’s a cognitive bias named after IKEA).

I digress. My point was that you have to provide solutions, not just tell people that things suck.

The How

The How is where we figure out how the homepage is sucking. In what way does it suck, now that we know that it does indeed suck? There are so many ways that a page can suck, maybe infinite ways. Here, we want to make an educated guess about how people are leaving.

Are they scrolling down the page, not finding what they want, and then leaving? Are they leaving immediately, like in less than 3 seconds? Where is their mouse going? Are they clicking on stuff that isn’t a link and then leaving?
These questions are tough to answer, but heatmaps and other tools that allow you to actually see a video of the user’s visit can provide some assistance. And rarely will all visitor behavior fit into one nice clean bucket so you have to look for patterns and make an educated guess.

The Why

This is where the money is made. Up to this point, we’ve been picking up clues but haven’t really hit on any big insights. The why is the insight-rich territory that can provide you answers and solid clues as to what is going on.

There are two basic approaches (that I can think of) for generating the why: listening and science. Listening is powerful as hell but only science will tell you if you were right.


By listening I mean listening to people that actually use the site. Just ask them and they’ll tell you the most amazing things like “I can’t find the pricing!” and “THIS SITE SUCKS WTF” and “where’s the schedule” and “tried to sign up but can’t find it” and “where do you ship” and “DO YOU TAKE VISA”.

Now, if you ask me, there’s more gold in those statements than in the analytics and if I had to choose between one or the other, I would go with listening instead of the analytics. For instance, how they say it can tell you a lot about the visitors socioeconomic status and education level.

And if you listen long enough, you’ll start to see clear patterns emerge that will inform your own hypotheses and guide you to the most significant obstacles to conversion on the site.

Listening can be done in many ways at different price points:

  • Do in-person user testing in a “usability lab” (no need for an actual lab, a normal room with a camera will do).
  • Use a service like usertesting.com.
  • Use an on-site survey program.
  • Have your mom use the site and talk about it as she does it.
  • Have the people at your company use the site.
  • Talk to the sales team, if there is one, and ask them what kind of things people say on the phone about the site or about their needs in general (their needs on the phone will be similar to their needs on the site).
  • Look back at the research that was originally done when the site was designed (one can hope).
  • Look at available research about your target market.


By science, I mean the scientific method. Formulate a hypothesis about why the bounce rate is low, then design an experiment to test that hypothesis. If you were able to use any of the methods in the Listening section, then you may already have some great hypotheses.

If not, then you can generate hypotheses on your own.

Look at the homepage. Does it do a good job of establishing the value proposition of the site? Does it clearly communicate what your site is about and why the visitor should be there? These and many other questions can help you generate hypotheses and I recommend reading this book by Chris Goward for more ideas.

Wrapping it up

Now you have something to talk to the client about. “We see that your sales are low and we think that it’s because your homepage isn’t engaging enough and visitors are leaving immediately. But don’t worry, because we did some research and we think that x, y, and z are the reasons that visitors are bouncing. We’re going to set up an A/B test to see if that improves the bounce rate. If not, those hypotheses will be ruled out and we can continue testing until we fix the problem.”



From FlowingData.com via Marginal Revolution.


How much should you invest in conversion rate optimization (CRO)? Should you invest in it all? Will it be a big waste of money?

As biased as I am, the answer for me is not always “yes, you should invest in CRO!” The opportunity costs of a single test or an entire testing program and have to be taken into account, whether you’re optimizing a website or yourself.

So, before you hire an expensive CRO agency, here’s a back-of-the-envelope calculation you can do to project the upside/downside of your investment:

Step 1: Estimate your site’s current conversion rate.

If you’re using Google Analytics/Adobe and have conversions set up properly then it should be just a matter of pulling up a conversion report.1


Step 2: Estimate your site’s current annual revenue.

For an eCommerce site, then just look at the revenue numbers for the same time period that you used to find your conversion rate. In the interest of making a good guess of future revenue, use a time period that represents a typical time for your site, meaning that if your business is heavily seasonal and generates most of its revenue in December, make sure you include more than the December revenue numbers.

It’s better to use an entire year’s data as the sample. If your site generates revenue through leads instead of transactions, there is a little guesswork involved because you probably rely on multiple touch points to make a sale (web form, media campaign, phone call, etc.).

Try to figure out the amount of revenue in the past 12 months that was directly influenced by someone filling out a lead form on your site.2

Step 3: Estimate your possible conversion rate lift

This part is truly guesswork, but let’s assume that you’re working with someone who gets good results and that you have an average site: the design looks pretty good but nobody has spent serious time and energy on improving the conversion rate. In that scenario, the expected conversion lift from a dedicated CRO working for 3-6 months would be 20-75%.

Again, this is a guess, but based on my experience and from talking to others, that’s a normal range (although sometimes results are much much more impressive, but you don’t want to put too much probability into that outcome).

Step 4: The Calculation

OK, so let’s take an example and do the math.

Site: AmazinglyCoolDesignerFurniture.com

Current conversion rate: 2.1%

Annual revenue (1/1/13 to 12/31/13): $300,000

A 20% lift in conversion rate would raise the conversion rate to 2.52% (2.1 x 1.2) and raise yearly revenue to $360,000.

A 75% lift in conversion rate would raise the conversion rate to 3.67% (2.1 x 1.75) and raise yearly revenue to $525,000.

NB: these calculations are rough because they assume that your traffic will stay the same. But that’s not necessarily a reason not to invest in CRO–an increase in conversion rate can also mitigate a drop in traffic by making the most of the fewer visitors you do receive.

Step 5: Subtract marginal costs and the costs of the CRO investment

Let’s work with higher end projection from the example above, an increase of yearly revenue that results in $525,000 in revenue per year. To review:

New revenue level: $525,000

Old revenue level: $300,000

Net increase: $225,000

Next, let’s factor in marginal costs. Revenue is great, but if you’re selling a product then there’s probably a cost associated with each additional unit you sell (even if your products just happen to be falling off the back of a truck you have to pay for *security*).

So let’s say that you sell a piece of furniture at $300 and each piece costs you $200 before you sell it. That’s $100 profit on each unit sold.

With this factored in, we have this:

Old Annual profit: $100,000

New, post-optimization annual profit: $120,000 to $175,000 (depending on how much lift you get from CRO).

Annual profit lift: $20,000 to $75,000.

Now you have a number you can work with! If you spend less than $20,000 on CRO, you have a very good chance of it paying off, with lots of upside built-in if the testing yields higher than a 20% lift. If you’re more optimistic (because you’re hiring a pro or because your site really sucks and has lots of room to grow), you can err on the side of the 75% lift and you have more room to play with.

You can take this back-of-the-envelope projection and use it to figure out your budget for CRO, whether you’re hiring a consultant, an agency, a new hire, or even if you’re considering doing it yourself and want to figure out if it’s worth it to spend many hours learning CRO yourself.


  1. If you’re not there yet with your tracking then step 0 would be getting tracking set up properly. But you can still estimate based on the number of transactions/leads you see in your backend system and dividing those by the number of visits you had in the same time period. 

  2. Educated guesses are OK at this point and let’s be honest, it’s how most business decisions are made. If you need to dress the projections up in fancy Excel spreadsheets later to sell it up the chain, then by all means do what’s necessary. We’re just trying to figure out right now if CRO is something worth pursuing. 


How to take a screenshot of an entire webpage

November 11, 2014

Need to take a screenshot of an entire page? The Webpage Screenshot plugin for Chrome is perfect. I love that you can also use it to mark up the image, take notes, etc. A great little tool for picking apart a page.

Read the full article →

Why aren’t people scrolling down the page?

October 27, 2014

One of the nifty features of CrazyEgg is the scroll map, which shows you how far down the page visitors are scrolling (hint: the further down the page, the fewer people there are). Sometimes you’ll see a particularly harsh drop off below the mystical fold, which could mean one of two things (that I can […]

Read the full article →

What I’m reading this week

May 17, 2014

This made me think… One Trick Ponies Get Shot. A gut-punch of a dissection of the way most digital agencies work and a better way to do things, how to create an actual marketing strategy and overcome the diminishing marginal returns of channel-specific tactics. I was going to write up all my thoughts on it, […]

Read the full article →

Notes and impressions from Opticon 2014

May 15, 2014

I posted my thoughts and impressions on Opticon 2014 up on envisionit media’s blog: Nerding out on CRO at Opticon.  

Read the full article →

Spec Case Study: Trunk Club’s Homepage

May 12, 2014

For my first case study, I’m going to talk about Trunk Club’s homepage because: a) I love the company, b) it’s a cool Chicago startup, and c) I love clothing. Caveats and Considerations I don’t have access to their analytics or any other data that’s not publicly available. I’m guessing that the smart marketers at […]

Read the full article →