ActiveCampaign Forum

Get the page URL when a form is filled


#1

Hey guys

Does anyone know how can I find where in my site the lead filled a form?

I have the same form in many pages, so it would be very important to know the exact URL the user was when the form was filled

Thanks a lot!


#2

Hey @eduardosh!

Here are two options for you. I’ll include one technical and one non.

First up is the technical: You can achieve this by adding a hidden field to each of your forms, and then populate it with Javascript. Your page URL location can be found in window.location.href, then just set your Javascript variable as the value of the hidden field. Let me know if you need more explanation!

Next is the the non-technical. This is really the fool-proof way, and will ensure that your contacts are directly attributed to a URL. Say you have a form on your contact page, your about page, and your team page. Let’s use a company/organization newsletter as the example. You would then create a form for each url with a naming convention, so you can easily reference a contact’s source.


#3

Hi @Ted !

Thanks for the quick reply

I’m not very familiar with coding, but I went for the technical option because it will be much easier for me in the future.

So, I created a new field for all my lists, got the field name and used the code below:

<input type='hidden' id='field[10]' name='field[10]' value='' />

And on my Javascript, this:

document.getElementById('field[10]').value = window.location.href;

When I open the contact on ActiveCampaign looks nice, already showing the URL. Thanks a lot.

Just another question: as it is a hidden field, how can I show it on the notification e-mails?
Should I use a ‘text’ field and hide it via CSS? Or is there another way?

Thanks a lot!!!

Cheers


#4

Fantastic! Happy to help :slight_smile: !

As it’s a notification email, all fields should come through in the message regardless of being hidden or not.


#5

Is it possible to achieve the same results using the API?


#6

Hey @eduardosh, I’m sorry I am not completely sure what you are asking?

It is possible to populate custom fields when adding a contact via the API (read more), and it is possible to retrieve custom fields when retrieving a contact via the API (read more)

Is that what you are wondering?


#7

how do I do the code above and where do I put it I’m a complete noob with coding thanks??


#8

Hi @eduardosh

I was very happy to find your solution. Unfortunately, it doesn’t seem to work.

What I did:

  1. I created a hidden custom field.
  2. I inserted it into my form.
  3. I checked the field number
  4. I added this code somewhere into my forms javascript
    document.getElementById('field[10]').value = window.location.href;
  5. I adjusted [10] with the correct field number.

Can you help me fixing this?

Thank you in advance!