gform_hubspot_submission_data

gform_hubspot_submission_data

DescriptionUsageParametersExampleChange value for pageNameRemove cookie valueCustom cookie valuePlacementSinceSource Code

Description

Allows the HubSpot submission data to be filtered before being sent to HubSpot.

Usage

The following would apply to all forms:

1add_filter( 'gform_hubspot_submission_data', 'your_function_name', 10, 4 );

To target a specific form, append the form id to the hook name. (format: gform_hubspot_submission_data_FORMID):

1add_filter( 'gform_hubspot_submission_data_1', 'your_function_name', 10, 4 );

Parameters

$submission_data array
The HubSpot submission data to be filtered. For more information about the data in this array, see HubSpot』s documentation.

$feed Feed Object
The current feed.

$entry Entry Object
The current entry.

$form Form Object
The current form.

Example

Change value for pageName

12345add_filter( 'gform_hubspot_submission_data', 'change_hubspot_submission_data', 10, 4 );function change_hubspot_submission_data( $submission_data, $feed, $entry, $form ){    $submission_data['context']['pageName'] = 'Testing by Gravity Forms';    return $submission_data;}

Remove cookie value

Using the following example a new contact will be created for each form submission, no matter if a cookie was set by the HubSpot tracking script in the visitor』s browser.

123456add_filter( 'gform_hubspot_submission_data', 'remove_cookie_value', 10, 4 );function remove_cookie_value( $submission_data, $feed, $entry, $form ){    GFCommon::log_debug( __METHOD__ . '(): running.' );    unset( $submission_data['context']['hutk'] );    return $submission_data;}

Custom cookie value

This example shows how you can replace the default cookie created by the HubSpot tracking script with your own custom cookie to define the hutk property.

12345add_filter( 'gform_hubspot_submission_data', 'custom_cookie_value', 10, 4 );function custom_cookie_value( $submission_data, $feed, $entry, $form ){    $submission_data['context']['hutk'] = rgar( $_COOKIE, 'your-cookie-name' );    return $submission_data;}

Placement

This code should be placed in the functions.php file of your active theme.

Since

This filter was added in HubSpot version 1.0.

Source Code

This filter is located in GF_HubSpot::generate_form_submission_object() in class-gf-hubspot.php.

發表回覆

您的郵箱地址不會被公開。 必填項已用 * 標註