When someone submits a Sign Up Form embedded on your website, the form sends a message to the page around it. A script on that page can listen for the message and do something with it, such as send the visitor to a thank-you page or record a conversion in Google Analytics or Meta Pixel. Most forms don't need this. It's for sites that track form completions in an outside analytics tool.
How Do I Run My Own Code When Someone Submits an Embedded Sign Up Form?
After a successful submission, the form sends a postMessage to the parent page in the format vc_form_complete~~~{submitted email}~~~{IP address, if available}. The form has to include an Email field, because the message is built from it. The script below listens for that message, checks that it came from v.vipecloud.com, and runs whatever code you put at the placeholder.
<script>
// Function for processing received events
function receiveMessage(event){
// event = vc_form_complete~~~{submitted email}~~~{ip address if avail}
if (event.origin !== "https://v.vipecloud.com"){ //security check
return;
}
var pieces = event.data.split('~~~');
if(pieces[0] === 'vc_form_complete'){ //confirm event type
// Action to complete on Sign Up Form Completion Goes Here!
// [REDIRECT/SEND TO ANALYTICS/ETC]
}
}
// Add the listener to start listening for form completions
addEventListener("message", receiveMessage, false);
</script>
In the left menu, click Automation.
Click Sign Up Forms.
Open the form you want to embed.
Click View Embed Code at the top of the form.
Copy the code from the Embed Code window and paste it on your web page, without changing the iframe's src address.
Paste the script above on the same web page.
Replace the two placeholder comment lines with the action you want, such as one of the examples below.
How Do I Send Visitors to a Thank-You Page After They Sign Up?
You can send people to a page of your own after they sign up, either with the form's built-in setting or with a script. The built-in setting needs no code, but on an embedded form it opens the new page inside the form's frame. Use the script when the whole browser window should go to the thank-you page.
How to Use the Form's Built-In Redirect
In the left menu, click Automation.
Click Sign Up Forms.
Open the form.
Click the Form Details tab.
Under What Does The Visitor See After Sign Up?, select Redirect To New Page.
Enter the page address in Redirect Url.
Click Save Visitor Sign Up Details.
The Conditional option in the same section sends people to different pages or messages based on their answers.
How to Redirect the Whole Page With a Script
To track the thank-you page in your analytics tool without more code, create a page-view event with a condition that page_location contains /thank-you, or the address of your thank-you page.
Paste this script on the same web page as the embedded form.
Replace https://yourcustomredirect.com/thank-you with the address of your thank-you page.
<script>
// Function for processing received events
function receiveMessage(event){
// event = vc_form_complete~~~{submitted email}~~~{ip address if avail}
if (event.origin !== "https://v.vipecloud.com"){ //security check
return;
}
var pieces = event.data.split('~~~');
if(pieces[0] === 'vc_form_complete'){ //confirm event type
window.location = 'https://yourcustomredirect.com/thank-you';
}
}
// Add the listener to start listening for form completions
addEventListener("message", receiveMessage, false);
</script>
How Do I Record a Sign-Up in Google Analytics?
This script records each sign-up as a generate_lead event in Google Analytics 4, so you can count form completions as conversions. Your site has to have the Google Analytics tag installed already. For help setting up a tag, see Google's setup guide.
Confirm the Google Analytics tag is on the web page with the embedded form.
Paste this script on the same web page.
<script>
// Function for processing received events
function receiveMessage(event){
// event = vc_form_complete~~~{submitted email}~~~{ip address if avail}
if (event.origin !== "https://v.vipecloud.com"){ //security check
return;
}
var pieces = event.data.split('~~~');
if(pieces[0] === 'vc_form_complete'){ //confirm event type
gtag('set', 'user_data', {
email: pieces[1]
});
gtag('event', 'generate_lead');
}
}
// Add the listener to start listening for form completions
addEventListener("message", receiveMessage, false);
</script>
How Do I Record a Sign-Up in Meta Pixel?
This script records each sign-up as a Lead event in Meta Pixel (Facebook Pixel), so your ad reporting counts form completions. Your site has to have the Meta Pixel code installed already. For details, see Meta's Pixel reference.
Confirm the Meta Pixel code is on the web page with the embedded form.
Paste this script on the same web page.
<script>
// Function for processing received events
function receiveMessage(event){
// event = vc_form_complete~~~{submitted email}~~~{ip address if avail}
if (event.origin !== "https://v.vipecloud.com"){ //security check
return;
}
var pieces = event.data.split('~~~');
if(pieces[0] === 'vc_form_complete'){ //confirm event type
fbq('track', 'Lead', {
content_name: "VC Form Completion", // placeholder
email: pieces[1]
});
}
}
// Add the listener to start listening for form completions
addEventListener("message", receiveMessage, false);
</script>
The same pattern works for other actions, such as sending a conversion to another ad platform or showing or hiding something on your page.
Troubleshooting
Why Doesn't My Script Run When Someone Signs Up?
The form only sends its message from an embedded form, after a successful submission. Check these in order:
The form has an Email field. Without one, no message is sent.
The script is on the same web page as the embedded form, not on a different page of your site.
The iframe's src address is the one from the Embed Code window. If it was changed to app.vipecloud.com, the script's check for v.vipecloud.com rejects the message.
The visitor signed up through the embedded form. The Landing Page Link opens the form on its own page, so there's no web page of yours around it to receive the message.
The analytics tag or pixel the script calls is installed on the page. If gtag or fbq isn't defined, the script stops with an error in the browser console.
Why Does My Thank-You Page Open Inside the Form?
The form's Redirect To New Page setting loads the new page inside the form's frame on your site. To send the whole browser window to the thank-you page, use the redirect script above and set the form back to Display Thank You Message.
Why Didn't My Script Run When the Form Was Full?
When a form has reached its sign-up limit, the visitor sees the form's thank-you message or redirect, but the form doesn't send the sign-up message, because no sign-up was recorded.
Key Notes
The message is sent only after a successful submission, and for forms that take a payment, only after the payment goes through.
The message carries the submitted email address and, when available, the visitor's IP address.
Keep the iframe's src on v.vipecloud.com. Don't change it to app.vipecloud.com.
For embedding steps, see How to Embed a Sign-Up Form on Your Website (Using an iFrame).

