This isn’t a post about why you should track goals on your website. I’ll assume you already know. Instead I’d like to talk about a problem I ran into while setting up a goal for my company’s ecommerce website and my solution.
When someone goes through the checkout process on our site the url’s look something like:
1) /cart
2) /session/new?return_to=%2Forders%2Fnew
3) /orders/new
4) /orders/3575/payment
5) /orders/3575/confirmation
Notice the dynamic url’s in numbers 3 and 4? After doing a little research I stumbled upon an informative post by Lunametrics, the comments section especially has a wealth of information about setting up goals with dynamic url’s. However, the examples provided didn’t fit my exact situation so I had write the following regular expressions.
1) ^/cart
2) ^/session/new
3) ^/orders/(?=new)
4) ^/orders/b0*[1-9][0-9]{0,8}b/(?=payment)
5) ^/orders/b0*[1-9][0-9]{0,8}b/(?=confirmation)

This will work for a range of numbers from 1 – 1,000,000,000. When we reach 1 billion orders I plan on putting a big flashing neon colored sign on the website announcing the fact. Just like McDonald’s does on the Golden Arch.
Be sure you’ve set Match Type to Regular Expressions in the goal information settings.
Hopefully this helps anyone who finds themselves in a similar situation.
Tags: analytics

blog







