Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Capturing the Referral URL


ollyno1uk2

Recommended Posts

Posted

Hi there

 

When someone places an order in my store I wish to see the original Referrer URL. I added this in application top but it seems at certain points the original referrer gets overwritten.

 

//HTTP_REFERER
 if (!$referer_url) {
  if ($HTTP_SERVER_VARS['HTTP_REFERER']) {
   $referer_url = $HTTP_SERVER_VARS['HTTP_REFERER'];
   tep_session_register('referer_url');
}
 }

 

I can't seem to find other with the same issue so perhaps I am doing something wrong?

 

Thanks a lot for any help that can be offered.

 

Olly

Posted

This is what the PHP manual has to say:

 

'HTTP_REFERER'

 

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

Hi there

 

Thanks for the response. I can understand why it wouldn't be 100% accurate but it seems the referrer is not being blocked but somewhere in OSC it is being lost or reset.

 

Is there any other solution for capturing referral url?

 

Thanks a lot

Posted

if (!$_SESSION['referer_url']) {

if ($HTTP_SERVER_VARS['HTTP_REFERER']) {

$referer_url = $HTTP_SERVER_VARS['HTTP_REFERER'];

tep_session_register('referer_url');

}

}

 

Thisshould do.

 

Satish

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Posted

$HTTP_SERVER_VARS is deprecated.

 

Personally I refrain from using it.

 

This is my version:

 

//HTTP_REFERER
if ( !isset( $referer_url ) ) {
 if ( strlen( $_SERVER['HTTP_REFERER'] ) ) {
$referer_url = $_SERVER['HTTP_REFERER'];
tep_session_register('referer_url');
 }
} else
 $referer_url = $_SERVER['HTTP_REFERER'];

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

  • 3 weeks later...
Posted

I tried using the code examples and I still get a similar issue.

 

It seems like at various stages throughout the checkout process the session is lost and the referral url then becomes a page within the store.

 

I guess OSC must be writing the session to a cookie or similar so that it picks it back up again as shopping cart data etc stays intact. It looks especially true when returning from a paypal checkout or a 3D secure check.

 

So I guess somehow I need to add the referral url to the part of OSC that remembers shopping carts and log ins etc.

 

If anyone has any clue about doing this I would be grateful to know.

 

Thanks a lot

Posted

It isn't getting lost. If you only want to capture it ONE TIME (the first time they enter the store) try this:

 

//HTTP_REFERER
if ( !isset( $referer_url ) ) {
 if ( strlen( $_SERVER['HTTP_REFERER'] ) ) {
$referer_url = $_SERVER['HTTP_REFERER'];
tep_session_register('referer_url');
 }
}

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

Hi Again

 

I still have a similar issue.

 

It seems that the page that is now being captured is the landing page. So we are getting closer to the solution but still not right!

 

Any ideas why it would treat the landing page as the referrer?

Posted

All the testing I've done (on two different sites/two different osC versions) with the code shows it to work flawlessly.

 

It captures the correct referring URL upon first entry to the store and it never changes.

 

If it doesn't work for you my guess is either you're losing the session or it's because it "cannot be trusted" (like the PHP manual says).

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

Hi

Thanks for the continued help.

 

I believe the reason that it cannot be trusted is because browsers can block this type of information from being passed. This is not happening here.

 

So I think that your other conclusion is that I am indeed losing the session. But how and why would this happen and where would I begin to look? The store is functioning as normal in all respects other than this.

 

Thanks a lot

Archived

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

×
×
  • Create New...