Question

Webhook and current page URL

  • 8 May 2023
  • 2 replies
  • 98 views

I am currently using Webhook to transfer data from Metform for Elementor to Google Sheets. However, since I am using the same form on several pages, I'm wondering if there's any way to obtain the URL of the page where the submission was made?


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +14

Hi @Goran 

Good question.

That likely has to be configured in Elementor.

 

Click Webhook tab to open its options.

  1. Webhook URL:Enter the integration URL (like Zapier) that will receive the form’s submitted data.
  2. Advanced Data: Slide to YES to send Advanced Data to the webhook, which will include meta data such as Date and Time, Remote IP, etc. It will also send the data as an array, such as:[ ‘Name’ => ‘John Doe’, ‘Email’ => ‘john@doe.com’, ‘Message’ => ‘Please contact me’ ]If Advanced Data is set to NO, the data will be sent in Simple form, which will send the form fields to the webhook as a text message, such as:“Name: John Doe, Email: john@doe.com, Message: Please contact me.”
webhook

I am currently using Webhook to transfer data from Metform for Elementor to Google Sheets. However, since I am using the same form on several pages, I'm wondering if there's any way to obtain the URL of the page where the submission was made?

To obtain the URL of the page where the submission was made when using Metform for Elementor and Webhook to transfer data to Google Sheets, you can follow these steps:

  1. Add a hidden field to your form: In the form builder of Metform for Elementor, add a hidden field to your form. This hidden field will capture the URL of the page where the form is embedded.

  2. Retrieve the current page URL: Use JavaScript to retrieve the current page URL. You can do this by adding a script to the page that will populate the hidden field with the URL.

Here's an example of how you can achieve this:

<script> document.addEventListener('DOMContentLoaded', function() { // Get the current page URL var currentPageUrl = window.location.href; // Set the value of the hidden field with the URL document.getElementById('hidden-field-id').value = currentPageUrl; }); </script>

Make sure to replace 'hidden-field-id' with the actual ID or name of your hidden field in the form.

  1. Pass the hidden field value through the Webhook: When the form is submitted, the hidden field value containing the URL will be included in the form data. Set up your Webhook configuration to transfer this data to Google Sheets along with the other form fields.