I got this rotating redirect code php

by 5 replies
6
I got this rotating redirect code php. You can have as many addresses as you want. Just ad another $aff[] = 'Put url here'; to the list. Is there a way to add google analytics on the same page as this code? I know I can put google analytics on the redirected pages. Can it be put on the same page as this code and work?

<?php
$k = $_GET['sub'];

$aff[] = 'Put url here';
$aff[] = 'Put url here';
$aff[] = 'Put url here';
$aff[] = 'Put url here';
$aff[] = 'Put url here';
$aff[] = 'Put url here';

srand ((double) microtime() * 1000000);
$random_number = rand(0,count($aff)-1);

$lol = ($aff[$random_number]);
$lal = $lol.$k;

header("Location: $lal"); ?>
#programming #code #php #redirect #rotating
  • Can anyone help with this?
  • <?php
    $k = $_GET['sub'];

    $aff[0] = 'Put url here';
    $aff[1] = 'Put url here';
    $aff[2] = 'Put url here';
    $aff[3] = 'Put url here';
    $aff[4] = 'Put url here';
    $aff[5] = 'Put url here';

    srand ((double) microtime() * 1000000);
    $random_number = rand(0,count($aff)-1);

    $lol = ($aff[$random_number]);
    $lal = $lol.$k;

    header("Location: $lal"); ?>

    All about PHP array ---> PHP Arrays

    No you cannot put analytics on a page redirecting usig PHP.
    Analytics uses Javascript that runs inside the clients web browser,
    this redirect uses PHP on your webserver. The visitor never sees
    anything that happens on this page only the redirect.
  • Is there other ways of rotating redirects that can be used with analytics?
  • In short, no you can't have analytics on this page. It wouldn't record any traffic.
    It is possible, but you would have to build your own stats tracking script; "off the shelf" analytics like google or piwik wouldn't do it without breaking the redirect.
  • tweakr is correct...this page will never hit the browser. The only thing that will get returned is the header redirect.

    You could record hits on this page, by using something like:
    INSERT INTO [the tracking db] (link, time) VALUES ('$lal, NOW())

Next Topics on Trending Feed

  • 6

    I got this rotating redirect code php. You can have as many addresses as you want. Just ad another $aff[] = 'Put url here'; to the list. Is there a way to add google analytics on the same page as this code? I know I can put google analytics on the redirected pages. Can it be put on the same page as this code and work? <?php