The safest way to track goal URLs in Google Analytics

How you can go about tracking your goal URLs in Google Analytics

I was recently digging into some analytics and I wondered why a goal I was tracking had stopped working, I decided to do some digging.

Turns out that I was looking for a page being hit with my destination being set to “Equals to” and passing in the page I was expecting. For example;

Destination URL Equals To: /thank-you-for-your-order/

For ages this worked like a charm, but recently the task that would send people to that page started adding some extra parameters to the URL, so the URL getting hit was /thank-you-for-your-order/?foo=bar.

This does not trigger my event because /thank-you-for-your-order/?foo=bar/thank-you-for-your-order/

The safer thing to do is actually something that to some folk my appear scary, that is to use the Regular Expression option.

Changing Equals To to Regular Expression in Google Analytics

For something simple like my use case the conversion is painfully simple, I needed to change to Regular Expression and change the input to;

^\/thank-you-for-your-order\/

The ^ says the following stuff needs to appear at the start of the URL and all the \ is doing is letting the Regular Expression know to not treat the / as anything special and that it is part of the string we care about.

If you want to convert yours and are having a hard time please just leave a comment and I can take a look!

Recent posts View all

Web DevProductivity

Keeping on top of website updates

Learn what website updates are, what they entail, why they are important, and how we can help

Freelancing

Getting the most out of your agency

Here are some tips based on years of working with, for, and as an agency on how to get the most out of any work you do.