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 …

Stick or Switch: Are you changing marketing lanes?

Stick or Switch: Are you changing marketing lanes?

Publishers are all looking for growth but, overall, sales are flat. Craig Riggs  of ReaderBound joked in a recent PubWest webinar, "flat is the new up." So many publishers are changing up their marketing, they are leaving Facebook and X, they are trying offline...

read more
AMA | Ask Me Anything

AMA | Ask Me Anything

I had 3 great marketing questions posed to me last week and I thought I'd share my responses. Question 1: Is there a way to show the Full URL of pages being shown in GA4 Realtime reports? Unfortunately there is no way to modify the Realtime reports. What you see is...

read more