2

I have an ASP site, and I am tracking traffic. The header includes the line:

<img alt="" src="http://xxxxxxxxx.co.uk/pixel.asp?visitorreferringurl=<% =Request.ServerVariables("HTTP_REFERER") %>" width="1" height="1" />

The target ASP page tracks the original referrer (from the passed query string) and the page the user is visiting (on the pixel.asp page this is actually the referer).

All is good.

I also have a Wordpress site (hence PHP) and I am trying to do the same. I can get pixel.asp to record but can't pass the referrer. I have tried..

<img alt="" src="http://xxxxxxx.co.uk/pixel.asp?visitorreferringurl<?php $_SERVER['HTTP_REFERER']; ?>" width="1" height="1" />

I also tried to declare the $_SERVER['HTTP_REFERER'] as a variable and then use that, but still no result.

Any suggestion please?

1
  • 1
    Missing the "echo" in your <?php $_SERVER.... ?> Commented Dec 14, 2015 at 14:27

2 Answers 2

2

You forgot to output the information in your variable.

Try this:

<?php echo $_SERVER['HTTP_REFERER']; ?>

Additional information:

You don't need to close the img tag with a trailing slash, so <img src="img"> is perfectly valid. Also, setting the alt attribute for the sake of setting it isn't useful, so either have some information there or drop it altogether.

Sign up to request clarification or add additional context in comments.

Comments

0

You need to use "echo" to output the variable. See: http://php.net/manual/en/function.echo.php

[img alt="" src="http://xxxxxxx.co.uk/pixel.asp?visitorreferringurl=<?php echo $_SERVER['HTTP_REFERER']; ?>" width="1" height="1" /]"

4 Comments

Didn't realize this. Fixed it. Thank you.
Thank you! Thought I had tried that... but it works perfectly!
but you didn't spot the deliberate error.. the missing equals sign before the php code.
@Nick Bridgens included that for you. Would be great if you choose an accepted answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.