PHP Redirect in Analytics?

by 1 replies
2
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.
#programming #analytics #php #redirect
  • 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
  • [DELETED]
  • Banned
    [DELETED]

Next Topics on Trending Feed