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

Hi,

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.

Dan

paulw paulw, 2 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, 2 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?

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098