Skip to content

conversion_bridge_ga4_event_data

Description

The conversion_bridge_ga4_event_data filter allows you to modify the event parameters sent with the gtag("event", ...) call before GA4 renders it. This is the data object that accompanies the event name — things like value, currency, items, label, and any custom parameters.

This runs after Conversion Bridge has prepared the event data for GA4's format. Use it to add, remove, or change parameters before the event fires.

Usage

add_filter( 'conversion_bridge_ga4_event_data', 'my_hook_function', 10, 1 );
add_filter( 'conversion_bridge_ga4_event_data', 'my_hook_function', 10, 1 );

Parameters

  1. $event_data (array) The event data array that will be JSON-encoded and passed as parameters to gtag("event", ...)

Example

Add a custom traffic_type parameter to all GA4 events so you can filter out internal traffic in your reports:

add_filter(
    'conversion_bridge_ga4_event_data',
    function( $event_data ) {

        if ( current_user_can( 'manage_options' ) ) {
            $event_data['traffic_type'] = 'internal';
        }

        return $event_data;
    }
);
add_filter(
    'conversion_bridge_ga4_event_data',
    function( $event_data ) {

        if ( current_user_can( 'manage_options' ) ) {
            $event_data['traffic_type'] = 'internal';
        }

        return $event_data;
    }
);

Still need help?

If you have not yet found your answer in the documentation articles, please contact support

Contact support