We have a number of redirecting pages in our CMS. These do not redirect across domains (such as vanity URLs), they are just to catch visits to old URLs that have changed. The redirects are not always landing pages, some of these redirects are visited in the middle of a session.
Technically, these pages return HTTP 301 without content. There is no possibility to use JavaScript code on the redirecting page, and not any custom server side code either.
Using Google Analytics, I wish to log both which redirects have been used, and where visitors came from. I don't want the redirect to trigger a new session start. And I don't want to pollute the list of visited pages with custom URL parameters.
Solutions we have tried:
- Plain redirects (/old-url -> /new-url) -- Source and Previous page path information is maintained, but it is impossible to see which pageviews came from redirects.
- Custom parameter (/old-url -> /new-url?redirect=/old-url) -- This makes all redirects identifiable and keeps all information, but pageviews are logged under a different URL.
- Campaign parameters (/old-url -> /new-url?utm_campaign=redirect&utm_medium=web&utm_source=/old-url) -- This logs pageviews under the correct url, and makes it possible to identify all redirects, but all source information is lost and the redirect triggers a new session.
There are two other solutions that I am considering, but I do not know exactly how to do this, and if it will even work for me.
- Run some custom JavaScript on the new URLs, that identifies a redirect and logs some measurable statistic in Google Analytics.
- Create a custom filter in Google Analytics that identifies a redirect (probably by a URL parameter?) and transforms this into some measurable statistic.