Title: Does plugin support Universal Analytics/UserId
Last modified: September 7, 2017

---

# Does plugin support Universal Analytics/UserId

 *  Resolved [atmojones](https://wordpress.org/support/users/atmojones/)
 * (@atmojones)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/does-plugin-support-universal-analytics-userid/)
 * Our client wants to create a User-ID Coverage report [https://support.google.com/analytics/answer/3123670](https://support.google.com/analytics/answer/3123670)
 * To do this we need to enable some things in our Google account, but we also need
   to pass a userId with the code `ga('set', 'userId', {{USER_ID}});` [https://support.google.com/analytics/answer/3123666](https://support.google.com/analytics/answer/3123666)
 * Does this plugin pass the wordpress user_id for logged in users in this parameter,
   and if not how can we go about getting this parameter passed in? Thank you for
   any help you can provide.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Alin Marcu](https://wordpress.org/support/users/deconf/)
 * (@deconf)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/does-plugin-support-universal-analytics-userid/#post-9478230)
 * Hi,
 * Here’s an example of tracking code customization;
 * [https://gist.github.com/deconf/db063aaea21974531c0bc42b502529a2](https://gist.github.com/deconf/db063aaea21974531c0bc42b502529a2)
 *  [BlazenWeb](https://wordpress.org/support/users/blazenweb/)
 * (@blazenweb)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/does-plugin-support-universal-analytics-userid/#post-9489304)
 * Thanks Alin. I need this too.
 * Any chance of a bit more info about updating that code?
    Before using GADWP I
   was doing this in functions.php with `ga('set', 'userId', <?php echo get_current_user_id();?
   >);`
 * Not quite sure how to use your code below correctly….?
 *     ```
       /* Analytics Code */
       function gadwp_addcode($gadwp) {
       	$commands = $gadwp->get(); // Get commands array
   
       	array_pop($commands); // Pop the last element
   
       	$fields = array();
       	$fields['hitType'] = 'pageview';
       	$commands[] = $gadwp->prepare( 'send', $fields ); // Add a new line to the commands array
   
       	$gadwp->set($commands); // Store the new commands array
       }
       add_action( 'gadwp_analytics_commands',  'gadwp_addcode', 10, 1 );
       ```
   
 *  [Alin Marcu](https://wordpress.org/support/users/deconf/)
 * (@deconf)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/does-plugin-support-universal-analytics-userid/#post-9489733)
 * Here you go:
 *     ```
       /* 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 );
       ```
   
    -  This reply was modified 8 years, 8 months ago by [Alin Marcu](https://wordpress.org/support/users/deconf/).
 *  [BlazenWeb](https://wordpress.org/support/users/blazenweb/)
 * (@blazenweb)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/does-plugin-support-universal-analytics-userid/#post-9489927)
 * Thanks so much Alin, that’s it! All working. Appreciate your help. Hopefully 
   this will help lots of people in the future that need to add the UserID in WordPress/
   GADWP/Google Analytics.
 *  [Biggytv](https://wordpress.org/support/users/biggytv/)
 * (@biggytv)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/does-plugin-support-universal-analytics-userid/#post-10022450)
 * Do I still need to add ga(‘set’, ‘userId’, {{USER_ID}}); to my header.php template?
 *  [jimjawn](https://wordpress.org/support/users/jimjawn/)
 * (@jimjawn)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/does-plugin-support-universal-analytics-userid/#post-10096583)
 * You should add this in as a checkbox. Awesome!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Does plugin support Universal Analytics/UserId’ is closed to new replies.

 * ![](https://ps.w.org/google-analytics-dashboard-for-wp/assets/icon.svg?rev=2243225)
 * [ExactMetrics - Google Analytics Dashboard for WordPress (Website Stats Plugin)](https://wordpress.org/plugins/google-analytics-dashboard-for-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-analytics-dashboard-for-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-analytics-dashboard-for-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/google-analytics-dashboard-for-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-analytics-dashboard-for-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-analytics-dashboard-for-wp/reviews/)

## Tags

 * [userid](https://wordpress.org/support/topic-tag/userid/)

 * 6 replies
 * 5 participants
 * Last reply from: [jimjawn](https://wordpress.org/support/users/jimjawn/)
 * Last activity: [8 years, 2 months ago](https://wordpress.org/support/topic/does-plugin-support-universal-analytics-userid/#post-10096583)
 * Status: resolved