Occasionally we hear from clients who are seeing the same URL twice in Google Analytics: once with a trailing slash and once without. While we can create redirects at the server level to automatically point all visitors to the slashed URL, there is a specific case where the redirect won't happen. When the page has already been cached, the NGINX proxy frontend will attempt to serve it as quickly and efficiently as possible. That means when it sees the non-slashed URL, it immediately serves the content rather than waiting for the server to redirect.
When that happens, both URLs will show up in your analytics. There are two options for handling this to get more accurate data:
1. You can "collapse" those URLs in your analytics into one single URL. You can do this yourself via the technique described here. This still allows your site to present your content as quickly and efficiently as possible but shows the data to you as a single URL.
2. We can set up a rule in NGINX (on your server) to redirect those non-slashed URLs to their slashed version even when the page has already been cached. This is a 301 redirect, so it's SEO-friendly, but it does introduce a (very, very small) delay in your page load times when the non-slashed URL is used. If you'd like us to do this for you, send us an email and we'll get it taken care of!
Please sign in to leave a comment.