Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 10th Aug 2012, 09:12 AM   #1
Advanced Warrior
War Room Member
 
vjboc's Avatar
 
Join Date: 2011
Location: Florida, U.S.A
Posts: 532
Thanks: 73
Thanked 45 Times in 34 Posts
Default
I got this rotating redirect code php
Share on: 
fb share twitter share gplus share more share

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 is offline  
Unread 10th Aug 2012, 11:13 AM   #2
Advanced Warrior
War Room Member
 
vjboc's Avatar
 
Join Date: 2011
Location: Florida, U.S.A
Posts: 532
Thanks: 73
Thanked 45 Times in 34 Posts
Default
Re: I got this rotating redirect code php
Share on: 
fb share twitter share gplus share more share

Can anyone help with this?
vjboc is offline  
Unread 10th Aug 2012, 06:00 PM   #3
Active Warrior
 
Join Date: 2012
Posts: 45
Thanks: 0
Thanked 9 Times in 9 Posts
Default
Re: I got this rotating redirect code php
Share on: 
fb share twitter share gplus share more share

<?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.
Lovelogic is offline  
Unread 11th Aug 2012, 07:45 AM   #4
Advanced Warrior
War Room Member
 
vjboc's Avatar
 
Join Date: 2011
Location: Florida, U.S.A
Posts: 532
Thanks: 73
Thanked 45 Times in 34 Posts
Default
Re: I got this rotating redirect code php
Share on: 
fb share twitter share gplus share more share

Is there other ways of rotating redirects that can be used with analytics?
vjboc is offline  
Unread 14th Aug 2012, 07:05 PM   #5
HyperActive Warrior
 
tweakr's Avatar
 
Join Date: 2011
Posts: 106
Thanks: 3
Thanked 12 Times in 11 Posts
Default
Re: I got this rotating redirect code php
Share on: 
fb share twitter share gplus share more share

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.

Free AdPress Theme for WordPress .
tweakr is offline  
Unread 25th Aug 2012, 04:52 AM   #6
HyperActive Warrior
War Room Member
 
Big Squid's Avatar
 
Join Date: 2009
Location: Living between LA & SD
Posts: 205
Thanks: 27
Thanked 36 Times in 33 Posts
Default
Re: I got this rotating redirect code php
Share on: 
fb share twitter share gplus share more share

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())
Big Squid is offline  
Closed Thread


Bookmarks

Tags
code, php, redirect, rotating


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




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