Jump to content

Server side Google Analytics and redirect


igurv

Recommended Posts

Hi,

I am trying to write a code for the page which auto redirects users, here is what the logic is

 

Based on the ISP location provided by users device, user will be directed to appropriate page - using [header("Location: pages/page.php");]

 

What I want is:

1. Before I redirect the users to the appropriate page - I want to be able to run the Google Analytics page on server and then do seamless redirection.

2. All this should happen on server side without loading HTML page or contents?

3. I am trying not to use Javascript code for google analytics

 

 

Is it possible?

 

Thanks

Ig

The header has to load some how correct? in which it will redirect based on the script thats being loaded with the header. That said a .php file is not limited to php code, which is what I think your thinking. Anything outside of the

 <?php ?>

tags will be interpreted at the very least as html by a browser and by the server serving it up. With that comes your  google analytics code which last I checked they only provided an api via javascript. There is no (which I could be very wrong) known html or php or other thing other than javascript to load analytics up on any page as just those couple lines connect to google and pool information it needs to run on its side of things to get your stats.

 

Bottom line is your serving a page for the redirect in one shape form or another. So within that page include the anylitics code google gives you and set the redirect to 1 or 2 seconds maybe 3 to 5 just to ensure analytics loads correctly before your script jumps to another.

Thanks for your reply!

The only reason - I am trying to stay away from JS is cause some clients may have JS turn off - in that case the stats are lost.

 

So I was wondering is google has something to jive with PHP like GAPI or Mobile version on GA...

 

Ig

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.