Custom Dimensions for Paid Memberships Pro
-
Hi Jeff,
Thank you so much for this plugin – I was searching for a non-affiliated Google Analytics plugin as we were previously using a plugin that was acquired and wanted something unaffiliated.
I’m writing up a recipe to set some custom dimensions for Paid Memberships Pro, specifically to track a logged in user’s “Membership Level”. I have a working recipe that tracks this data and just hoped to get your eyes on how the code is working.
In this case the custom code is added via a filter to the
gap_custom_code
hook.function custom_dimensions_membership_level( $custom_code ) { $membership_level = ''; // Get the value to track for the current user. if ( is_user_logged_in() && function_exists( 'pmpro_getMembershipLevelForUser' ) ) { // Get the current users's membership level ID. $current_user_membership_level = pmpro_getMembershipLevelForUser( get_current_user_id() ); $membership_level = $current_user_membership_level->ID; } else { // Set the tracked membership level ID to no_level. $membership_level = 'no_level'; } if ( ! empty( $membership_level ) ) { $custom_code .= "ga('set', 'dimension4', '" . $membership_level . "' );"; } return $custom_code; } add_filter( 'gap_custom_code', 'custom_dimensions_membership_level' );
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Custom Dimensions for Paid Memberships Pro’ is closed to new replies.