Last active
March 15, 2018 19:28
-
-
Save deconf/23cbc2b169c8334edef2ed4d54de3cd6 to your computer and use it in GitHub Desktop.
Adds userId support for Universal Analytics in GADWP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Analytics Code */ | |
function gadwp_addcode( $gadwp ) { | |
$commands = $gadwp->get(); // Get commands array | |
$fields = array(); | |
$fields['option'] = 'userId'; | |
$fields['value'] = get_current_user_id(); | |
if ( $fields['value'] ){ | |
$command = array( $gadwp->prepare( 'set', $fields ) ); | |
array_splice( $commands, -1, 0, $command ); //insert the command before send | |
} | |
$gadwp->set( $commands ); // Store the new commands array | |
} | |
add_action( 'gadwp_analytics_commands', 'gadwp_addcode', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment