In every WordPress form, you are able to define a JavaScript function which is called when a form was submitted. This feature is useful for any kind of tracking events. For example, you can track conversions with Google Analytics Tracking Events, add Facebook Pixel and so on.
This article shows how you can call events / conversions on form submissions.
Integrate Google Conversion Code
If you didn’t set up any tracking events on your WordPress site yet, follow these steps:
-
- In your Google Ads dashboard, click on Tools -> Conversions
- Add a new conversion action, click on Website, set up your conversion and make sure the Attribution model is set to Last click
- Click on Create and continue
- Select Install the tag yourself
- Insert the global site tag to your page (add custom javascript code the right way)
- Select Click in Event Snippet
- Copy the snippet and add it to your page (see #5)
- In your WordPress admin dashboard, go to ez Form Calculator -> Global Settings
- Set Enable custom JS to Yes
- Add the following code to the Custom JS option:
1234567function ezfc_track_event(vars) {// make sure the google tag report function existsif (typeof gtag_report_conversion !== "function") return;// your tracking event heregtag_report_conversion(window.location.href);} - Go to the ez Form Calculator dashboard, open up your form, click on Form options -> Form -> Find the option JS function after submission and set the value to ezfc_track_event