Tagged: Partner logo element, woocommerce
Hello,
We’d like to track any clicks on a logo/partner element block. We are using the WooCommerce Google Analytics Pro Plugin, which in the dev documents give us the following code:
if ( ! function_exists( ‘my_custom_event_function’ ) ) {
function my_custom_event_function() {
wc_google_analytics_pro()->get_integration()->custom_event( ‘Event name’, array( ‘Property name’ => ‘value’ ) );
}
add_action( ‘hook_to_trigger_event_on’, ‘custom_event_function’ );
}
However, we need a hook to fire this function within this section? Can you provide any assistance?
Many thanks,
James
Hey JustCodingStuff,
Thank you for using Enfold.
Looking at the snippet, seems like you can only trigger that function on page load because it has to be inside an action callback. You might be able to trigger it on a click event using AJAX, but that would require modification that is beyond the scope support. Please contact the plugin authors for more info.
A quick example of an AJAX script can be found in this article.
// https://medium.com/techcompose/how-to-use-ajax-precisely-in-wordpress-custom-themes-dc61616720a8
Best regards,
Ismael