It is also possible to add a regular expression filter in GA itself that will add slashes inside, effectively fixing the problem.
From https://www.getelevar.com/how-to/fix-duplicate-url-google-analytics/
How to fix duplicate URLs in reports
Step 1: create a new GA view so you can check and verify if this hotfix works before applying it to your daily view.
Step 2. Create a new advanced filter with this regular expression (screenshot below) that performs this manipulation of your data:
If the URL has no request parameters at the end of the URL and is a standalone URL And does not have a trailing slash at the end of the URL, then add a trailing slash at the end of the URL
The following is a regular expression for an extended rule:
^(/[a-z0β9/_\-]*[^/])$
Once this is done, save your filter.
Step 3: Verify that the new filter is working as expected.
To check and verify if this works, follow these steps: you can use the real-time report in Google Analytics to:
In one browser tab, navigate to the version of your site that you would like to test (for example, yourdomain.com/new-in) In a second additional browser tab, navigate to the version of the same URL with a trailing slash (for example, yourdomain.com/ new-in /) Go to Google Analytics> Real-time Report> Top Active Pages, and you should have 2 active pages from the previous steps!
source share