WooCommerce Google Analytics Pro Social Login Integration
<?php | |
/** | |
* Tracks a social login authentication event with Google Analytics Pro. | |
* | |
* @param int $user_id the ID of the user that was just authenticated | |
* @param string $provider_id the social login provider ID that authenticated the user e.g. `facebook` | |
*/ | |
function sv_wc_google_analytics_pro_track_social_login_authentication( $user_id, $provider_id ) { | |
// event name | |
$event_name = 'social login authentication' | |
// event properties -- see https://developers.google.com/analytics/devguides/collection/analyticsjs/events for more details | |
$properties = array( | |
'eventCategory' => 'category', | |
'eventAction' => 'action', | |
'eventLabel' => 'label', | |
'eventValue' => 100, | |
); | |
// additional enhanced ecommerce data to send with the event -- will have to read the code for more details on this param. | |
$ec = array(); | |
// (optional) identities to use when tracking the event - if not provided, auto-detects from GA cookie and current user. | |
$identities = array(); | |
// true/false -- whether the event is an admin event or not | |
$admin_event = false; | |
wc_google_analytics_pro()->get_integration()->api_record_event( $event_name, $properties, $ec, $identities, $admin_event ); | |
} | |
add_action( 'wc_social_login_user_authenticated', 'sv_wc_google_analytics_pro_track_social_login_authentication', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment