Use this reference to send custom events from WooCommerce Google Analytics Pro to a GA4 property. Set up GA4 tracking in WooCommerce before adding a site-specific plugin that calls the event API. Test with an approved test property and fictional activity.
Note:
This is a developer-level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customization work. We are unable to provide support for customization under our Support Policy.
Record a custom event
↑ Back to topThis example registers a callback for a store-specific WordPress action. Replace my_store_size_guide_opened with an action that runs once when the behavior occurs on your site. The action in the example is a placeholder and your implementation must supply it.
add_action( 'my_store_size_guide_opened', function () {
if ( ! function_exists( 'wc_google_analytics_pro' ) ) {
return;
}
wc_google_analytics_pro()
->get_tracking_instance()
->get_event_tracking_instance()
->custom_event(
'store_size_guide_opened',
array( 'guide_location' => 'product_page' )
);
} );
Pass an event name and, optionally, an array of event properties. Follow Google’s event naming rules. Use nonpersonal values and avoid names already used by the integration.
Verify the event
↑ Back to topWith a test property connected, enable Debug Mode temporarily and trigger your chosen action. Open DebugView to confirm that the expected event and parameters appear once. If the event is missing, verify the hook runs and check the tracking settings and connection. Disable debug mode when finished.
Check other tracking integrations
↑ Back to topUse the WooCommerce guide’s purchase and referral reporting and duplicate-tracking guidance when Google Tag Manager is also installed. Legacy Universal Analytics pageview snippets do not configure GA4 pageview tracking.
Questions and support
↑ Back to topSomething missing from this documentation? Still have questions and need assistance?
- If you have a question about a specific extension or theme you’d like to purchase, contact us to get answers.
- If you already purchased this product and need some assistance, get in touch with a Happiness Engineer via our support page and select this product’s name from the Product dropdown.