Manual FB Conversion Tracking

Hi all,
I have just taken over the administration of a Wordpress homepage. I have got the following tasks. First add the Meta pixel code in all headers of the page. This I have done, and it is working.
Second task is to add Facebook conversion tracking for two Gravity Forms on the page. Both are contact forms that, when a user presses submit, should get registered as a “Lead” with Meta Pixel.
What I have done is installed Code Chest, and added this code:
$( ‘#gform_GFFORMID’ ).on( ‘submit’, function() {
fbq(‘track’, ‘Lead’);
} );

But no Lead have been registred.

With Gravity Forms 2.9 and greater, the recommended way to perform a custom action between the submit button being clicked and the request being sent to the server is to use the new gform/submission/pre_submission filter:

2 Likes

Hi Utveck,

The following code might help register a user as a lead upon clicking the submit button.

document.addEventListener('gform/postRender', (event) => {
    gform.utils.addAsyncFilter('gform/submission/pre_submission', async (data) => {
        const specificFormId = 'YOUR_FORM_ID'; // Your GF form ID
        if (data.formId === specificFormId && data.submissionType === gform.submission.SUBMISSION_TYPE_SUBMIT) {
            fbq('track', 'Lead');
        }
        return data;
    });
});

Give it a try, and let me know how that goes! :smile:

1 Like