The default method of capturing and reporting on Ninja Forms (a WordPress Plugin) form submit events using the 6sense WebTag does not work on some websites. Usually it does not work because:
The Ninja Forms validation feature blocks the inherent HTML form submit event from propagating to the 6sense web beacon,
The Ninja Forms form is embedded in an iframe,
Or both.
To capture and report the form submits in these cases, follow these steps.
Step 1: Place or Update the 6sense WebTag If Not Already Present
Navigate to Settings > WebTag.
In the Configure Domains to Accept Data section, make sure the Your Domains list (the allow list) includes the URL that the Ninja Forms form is hosted on.
If the form is placed in an iFrame, add the domain of the landing page in which the iFrame is placed to the Your Domains list.
If the URL is a subdomain of an already-allowed domain, you do not need to add a separate subdomain to the Your Domains list.
Get a copy of your webtag by navigating to Settings > WebTag. In the Copy Code Snippet section, press the Get Tag button. Your tag will be displayed for 10 seconds. Copy the tag code snippet that is displayed. The webtag code snippet should look similar to this:
<script> window._6si = window._6si || []; window._6si.push(['enableEventTracking', true]); window._6si.push(['setToken', 'YOUR_TOKEN_WILL_ALREADY_BE_HERE']); window._6si.push(['setEndpoint', 'b.6sc.co']); (function() { var gd = document.createElement('script'); gd.type = 'text/javascript'; gd.async = true; gd.src = '//j.6sc.co/6si.min.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gd, s); })(); </script>
Instead of YOUR_TOKEN_WILL_ALREADY_BE_HERE, a specific token for your 6sense webtag is included in the code snippet.
Place this tag in your website’s HTML right after the starting <head> tag.
If you are using a tag manager, have the custom script tag fire as soon as possible.
If are using a hosted landing page but not a tag manager, add the tag in the landing page template applicable to your form.
Step 2: Add an Additional Script to your Form Page
To accurately recognize Ninja Forms form submission events, we utilize the Ninja Forms Form Extensions to Listen to the Submit Response.
Copy the following code:
<script>
if (typeof Marionette != "undefined") {
function nfFormDataParse(formData) {
var fieldData = {};
for (field in formData) {
var fieldValue = formData[field].value;
fieldData[field] = fieldValue;
}
return fieldData;
}
window._6si = window._6si || [];
var mySubmitController = Marionette.Object.extend({
initialize: function() {
this.listenTo(Backbone.Radio.channel('forms'), 'submit:response', this.actionSubmit);
console.info("6sense: Form submit initiated.");
},
actionSubmit: function(response) {
var nfFormDataParsed = nfFormDataParse(response.data.fields_by_key);
window._6si.push(['sendFormData', nfFormDataParsed]);
// print to console for validation (remove once validated)
console.info("6sense: Form submit completed.");
console.info("6sense: formData sent: " + JSON.stringify(nfFormDataParsed));
},
});
jQuery(document).ready(function($) {
new mySubmitController();
});
}
</script>
Place this tag in your website’s HTML right after the starting <head> tag.
If you are using a tag manager, have the custom script tag fire as soon as possible.
If are using a hosted landing page but not a tag manager, add the tag in the landing page template applicable to your form.
Troubleshooting
To validate success using either of the options detailed, look for the Developer Console Log messages of “6sense: Form submit initiated.” and “6sense: Form submit completed” to be present when testing form submits.
If the desired form submit event data is not present within your 6sense instance for the effected forms, please work with 6sense Support to further troubleshoot.
FAQ
Q: Do I have to adjust every Ninja Forms form embed code?
A: No, if the script provided is present and firing on every page a Ninja Forms form is present, you do not need to adjust the form code.
Q: Do you support other types of forms?
A: This code only provides a workaround for Ninja Forms WordPress forms.
Q: I’m seeing discrepancies between the information in my 6sense Influenced Form Fills report and my own count of form fills from my Ninja Forms reports or web analytics. Could following this guide resolve that issue?
A: If you are reporting on Ninja Forms forms and do not see form fills in your 6sense display ad campaign Influenced Form Fills metric, following this guide may solve the problem.