Gravity Forms

If you use Gravity Forms on your website please use this documentation to send conversions from your website to Ruler.

📘

Gravity Forms Version 2.9

Gravity Forms Version 2.9 is a major Gravity Forms update introduced in 2024. If you are using Gravity Forms Version 2.9 or later please use the script below to track conversions from Gravity Forms.

If you are using an earlier version of Gravity Forms, please email [email protected]

Implementation Guide

Choose the relevant gravity form script from the options below based on whether you use a single page form or have a multi step setup. The scripts can be added to every page of your website, including pages that don't contain a Gravity Form.

We recommend implementing the script via Google Tag Manager, as a custom HTML tag, the Script the tag trigger should be selected as the_ 'DOM Ready' _trigger.

However, If you are unable to load via GTM and are applying the script directly to your site, ensure the code is wrapped in a "document ready" wrapper, before the closing </body> tag to allow for loading delays.

Single Page Gravity Forms

This is for non multi step forms. Apply this script to the footer of your website before the closing </body> tags.

<script>
    if (typeof gform !== 'undefined' && gform.utils && typeof gform.utils.addAsyncFilter === 'function') {
        gform.utils.addAsyncFilter('gform/submission/pre_submission', function (data) {
            return new Promise(function (resolve, reject) {
                try {
                    var payload = {};
                    
                    for (var i = 0; i < data.form.length; i++) {
                        var id = data.form[i].id;
                        var value = data.form[i].value;

                        if (data.form[i].type === "email") {
                            payload.email = value;
                        } else if (id && value) {
                            payload[id] = value;
                        }
                    }

                    try {
                        RulerAnalytics.trackConversionAsync(payload, "", "", 500);
                        resolve(data);
                    } catch (error) {
                        resolve(data);
                    }
                } catch (ex) {
                    resolve(data);
                }
            });
        });
    }
</script>

Multi Step Gravity Forms

For Multi Step forms that contain a 'next' button in between the final submission, please use this script instead.


<script>
    if (typeof gform !== 'undefined' && gform.utils && typeof gform.utils.addAsyncFilter === 'function') {
        gform.utils.addAsyncFilter('gform/submission/pre_submission', function (data) {
            return new Promise(function (resolve, reject) {
                // Only fire on final form submission, not on "Next" or "Previous" page clicks
                if (data.submissionType !== 'submit') {
                    resolve(data);
                    return;
                }

                try {
                    var payload = {};
                    
                    for (var i = 0; i < data.form.length; i++) {
                        var id = data.form[i].id;
                        var value = data.form[i].value;

                        if (data.form[i].type === "email") {
                            payload.email = value;
                        } else if (id && value) {
                            payload[id] = value;
                        }
                    }

                    try {
                        RulerAnalytics.trackConversionAsync(payload, "", "", 500);
                        resolve(data);
                    } catch (error) {
                        resolve(data);
                    }
                } catch (ex) {
                    resolve(data);
                }
            });
        });
    }
</script>


❗️

Script only compatible with Gravity Forms Version 2.9 or later

If you are using an earlier version of Gravity Forms, please email [email protected]