Tncmk
Tncmk

Reputation: 169

Identifying submitted page url for Contact form 7

I am currently using a single form through Contact Form 7 for visitors to download pdf files on my website. Once they fill the form and clicking the submission button, the related pdf file will be downloading.

However, I want to export the information about visitors whoever downloaded the pdf file for a specific page. I downloaded the report from Contact Form DB but it does not show any link or page name that visitors submitted the form. I believe there is a way to identify or fixing this.

Thank you

Upvotes: 1

Views: 12659

Answers (2)

Daniel Ellis
Daniel Ellis

Reputation: 334

If you'd rather not add an extra plugin, it's also possible to record which page a user submitted a CF7 contact form from using a hidden field and a little bit of inline JavaScript.

Here is an example of what such a CF7 template might look like:

<label> Message [textarea message] </label>

[hidden page-url]

<script>
document.querySelectorAll('.wpcf7 input[name="page-url"]').forEach(function(element) {
  element.value = window.location.href;
});
</script>

[submit "Submit"]

Basically, the embedded script here is finding all instances of CF7 inputs with the specified name ("page-url" in this case) and changing their value properties to the page's current URL, which is determined using the window location.

Upvotes: 1

vicente
vicente

Reputation: 2643

You can use the Contact Form 7 Dynamic Text Extention.

Use the shortcode below in your form to retrieve the current page URL:

[dynamictext yourfieldname "CF7_URL"]

Upvotes: 3

Related Questions