How Do I Capture the Referrer URL on Web Sign Up Forms


I've been pulling my hair out trying to work out how to capture the user's referrer URL when people sign up using an online form on a landing page on my clients website.

I've created a hidden field when creating a subscribe form in Campaign Monitor to receive this information, the code is below:

<input id="fieldmhkti" name="cm-f-mhkti" type="hidden" />

What javascript or PHP code do I put in the header to provide the referrer URL?

Your help is greatly appreciated.


paulw paulw, 3 years ago

Hi Dan!

It may be possible to add the following code to your input tag to set that up:

value="<?php echo $_SERVER['HTTP_REFERER'] ?>"

However this does rely on a number of different factors and it’s difficult to know whether this will work okay in this situation. Feel free to contact support with some further details of what you want to do and we can help out :)

The Campaign Monitor Blog – HTML email smarts to go with your good looks.
InBlue, 3 years ago

Hi Paul.

Thank you for your prompt response. I put that in my code, ran a test, and instead of displaying the referrer URL, it just displayed the code you posted. Any other ideas?

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free