Description
The gform_googleanalytics_pagination_event_name
filter hook can be used to filter the name of the pagination event to be sent to Google Analytics. This filter only applies to Google Analytics or Measurement Protocol (not Tag Manager).
Note: For more information about restrictions on resetting the event name, refer to [GA4] Event naming rules – Analytics Help.
Usage
Applies to all forms:
add_action( 'gform_googleanalytics_pagination_event_name', 'your_function_name', 10, 3 );
Parameters
- $event_name string
The event name sent to Google Analytics. Default isgforms_pagination
. - $mode string
Google Analytics connection mode. “ga” for Analytics, “gtm” for Tag Manager, “gmp” for Management Protocol. - $form Form Object
The form currently being processed.
Examples
1. Append form ID to event name
add_filter( 'gform_googleanalytics_pagination_event_name', function( $event_name, $mode, $form ) {
return "{$event_name}_{$form['id']}";
}, 10, 3 );
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Since
This action hook was added in Google Analytics v2.0.0
Source Code
This action hook is located in class GF_Google_Analytics
in /class-gf-google-analytics.php.