Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   I got this rotating redirect code php (https://www.warriorforum.com/programming/652379-i-got-rotating-redirect-code-php.html)

vjboc 10th August 2012 09:12 AM

I got this rotating redirect code php
 
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"); ?>

vjboc 10th August 2012 11:13 AM

Re: I got this rotating redirect code php
 
Can anyone help with this?

Lovelogic 10th August 2012 06:00 PM

Re: I got this rotating redirect code php
 
<?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.

vjboc 11th August 2012 07:45 AM

Re: I got this rotating redirect code php
 
Is there other ways of rotating redirects that can be used with analytics?

tweakr 14th August 2012 07:05 PM

Re: I got this rotating redirect code php
 
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.

Big Squid 25th August 2012 04:52 AM

Re: I got this rotating redirect code php
 
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())


All times are GMT -6. The time now is 12:30 AM.