PHP Redirect in Analytics?

1 replies
Hello Warriors!
How do I make a php redirect:
<?php header('Location: url'); ?>
to show as a page view in google analytics? Right now I am using an html redirect with a time delay and analytics script in it for this purpose, but php would be preferable.
#analytics #php #redirect
  • Profile picture of the author frank007
    Originally Posted by liondragon View Post

    Hello Warriors!
    How do I make a php redirect:
    <?php header('Location: url'); ?>
    to show as a page view in google analytics? Right now I am using an html redirect with a time delay and analytics script in it for this purpose, but php would be preferable.
    Hello,

    You can do it like, place the following code at the top of page which you want to redirect:

    <?php
    header( "HTTP/1.1 301 Moved Permanently" );
    header( "Location: YOUR-DESTINATION-URL-HERE" );
    ?>

    and below this add your google tracking code, also in the destination url put the same code. Check your Google Analytics report, your page would be there
    {{ DiscussionBoard.errors[5550701].message }}

Trending Topics