Blog

+ Free advice and other musings

Remove Trailing Slash in Google Analytics

by | Nov 30, 2021 | Google Analytics

Have you ever run your Google Analytics > Behaviour > Site Content > All Pages report and been discouraged to find duplicate URLs? In particular some that are yourdomain.com/article and yourdomain.com/article/

B’ah that trailing slash means you have to export and aggregate the data. Computers are dumb. To a computer, /article and /article/ are two different things. To a human, the URL goes to the same page. It’s nice to be human.

Most of the Shopify sites that we report on favour the url without the trailing slash, but sometimes the trailing slash appears so the simply thing to do is to remove the trailing slash from Google Analytics by using a filter.

You can, of course, get your web developer to write some code that adds or removes the trailing slash, and there are ways to set a preference in wordpress, but if you’re still finding them appearing then use a filter.

Log into Google Analytics and go to Admin. In the far right under Views click Filter > Add a Filter.

Give a Filter Name, eg. “Remove Trailing Slash”

Then Filter Type is Custom > Advanced

Now, some people set up a Search and Replace filter, but I do Advanced.

Field A -> Extract A
Request URI ^/(.*)/$

Output To -> Constructor
Request URI
/$A1

Use Filter Verification to confirm that it will work for your setup. Then SAVE.

Happy reporting!

You may also like …

How to Track Marketing Campaigns in GA4

How to Track Marketing Campaigns in GA4

Holiday campaign tracking provides insights into what's working or not working. But you need to set it up. It's 5 weeks and 3 days until Black Friday, and even if your business is not located in America, this retail event kicks off the holiday shopping season around...

read more