Scoring a goal against google is never easy. Google analytics allows you to do some strange and wonderful things, but not without some teeth grinding. I was struggling with this for a little while, and it was a great source of frustration, since there’s hardly any info out there about it. Or maybe there is lots of info, but no solution to this particular problem. I think I finally nailed it.
Dynamic Goal Conversion Values
I was trying to get some dynamic goal conversion values into Analytics. I ended up reading about Ecommerce tracking and it seemed like the way to go. Not only would I be able to pick the goal conversion value dynamically, it gives you a breakdown of each and every transaction. Very nice. After implementing it, I was quite impressed to see each transaction, product, sku etc appear neatly on the ecommerce reports. So far so good. But somehow, goals – which were set on the very same page as the ecommerce tracking code – failed to add the transaction value. The goals were tracked just fine, I could see them adding up, but not the goal value. grrrr…
I was particularly frustrated after meticulously reading through the Ecommerce Transaction Page Goals, which is very clear about this being possible, as long as you set the conversion value to zero.
There’s a small thing that doesn’t seem to get mentioned anywhere, and I’m still not sure why it causes a problem. If it doesn’t work for you, I have a few alternative approaches worth trying too…
I discovered that in my case, the google analytics code was included on the goal conversion page twice. Once, as in every page, the standard tracking code on the header. And again on the body, together with the ecommerce tracking values. Both were running fine, and as I mentioned the results appeared. But somehow it seems to create some conflict. Removing the ‘standard’ tracking section seemed to have solved this mysterious problem.
Here’s what the HTML looked like – Remove the first part
Since analytics seem to encompass lots of black magic, I’m still not 100% sure that’s the only possible solution. However, along the way I discovered some other interesting things…
Instead of goal tracking by URL, you can actually track an event. If you’ve already coded the ecommerce tracking section anyway, adding event tracking to it is a doddle. Simply add this line somewhere before or after the ecommerce tracking code
_gaq.push(['_trackEvent', 'Cart', 'Checkout', 'Success', 39.99]);
In this case I defined the event category to be ‘Cart’, the action to be ‘Checkout’, the option to ‘Success’, and the value to 39.99. Once you do that, you can set your goal to use an Event instead of a URL. Here’s more on info on setting the event goals and choosing the value as the conversion value.
If your main concern is tracking conversion values, and you’re not too fussed about the whole ecommerce tracking, then this is actually a much easier way. All you need is one line of code. It can however work perfectly well together with your existing ecommerce tracking.
Wet paint – slow updates
Analytics seems to update rather slowly. It also seems to update and un-update some data if you keep refreshing. You see a new transaction. You refresh. It’s gone. Refresh again, it’s back… This is normally not a huge problem, just confusing, but when you’re trying to debug something, can make things much more difficult. For example, if you update your Goal configuration. Say you change the URL, or the tracking event, or added a new goal. It might take a good few minutes for it to update. If you trigger the goal, e.g. by going to the URL page, it might not trigger – because Analytics still uses the old goal settings. You simply have no way to find out whether the goal is active or not. You must wait for the paint to dry before you try anything new.
A couple of more things to watch out for:
- The Ecommerce page says that
For URL: Supply the URL for your shopping cart. For example: http://www.we-sell-for-you.com/mysite/myCart.asp
In most cases, you only need to supply the relative path, e.g. /mysite/myCart.asp
- I’m not sure whether it makes a difference, but if you’re using _gaq.push([‘_setDomainName’, ‘.domain.com’]);, this might also cause some issues? (didn’t test this explicitly though)
Hope this is helping someone. I was pulling my hair over this so hope I can save some other people’s hairline from receding. The time it takes for the goal/ecommerce tracking to appear on analytics also makes testing it rather long and much more difficult to resolve. Having tested a few too many different combos, I’m still not 100% sure this is a bullet-proof solution, but I’m definitely seeing some goal conversion values now.
UPDATE: looks like it will only work if you also use event tracking. With URL tracking alone it doesn’t seem to pick the goal values.