: How can I get Google Analytics to report my semantic URL requests more accurately? I have implemented "friendly" URLs, also called "semantic" URLs, on my website, using code similar to this answer
I have implemented "friendly" URLs, also called "semantic" URLs, on my website, using code similar to this answer on Stack Overflow.
I've set it up so that the URL will direct to a specific name format so the right page will be retrieved. So if a user comes to the site by any of these links:
example.com/Some Crazy Page example.com/SOME CRAZY PAGE example.com/some%20crazy%20page
They will end up here:
example.com/some_crazy_page
The problem is that when my page redirects the user to the page with the right format, it essentially reloads the page as if it were a new HTTP request. This seems to make Google Analytics see each conversion as a new page visit. Which in turns mean that when I look at my Google Analytics data, I'm seeing thousands of hits on my website top page, displayed simply as / in the Analytics interface. It looks like my top page is by far the most popular page, when I know for sure that isn't the case.
Is there a way I can get Google Analytics to filter out all these initial redirects? I'm thinking something like "any time a user lands on / and the session is no longer than 1 second". Or if I could filter out all 301 permanently moved redirects... Or maybe someone has a more clever solution.
My .htaccess file contains this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
My PHP code is complicated, so forgive me if I'm not including the right information, but it contains this (please let me know if there's more I should show):
public static function redirectURL ($articleName)
{
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: ' . Session::getSession ()->encodeSessionID ($articleName));
exit;
}
More posts by @Shanna517
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.