This plugin supports logged-in user ID tracking for Universal Analytics properties (not GA4).
Play around with the live demo.
A GA4 version may be in the works.
- Download the latest release (zip file) from GitHub.
- Log in to your WordPress site as an admin.
- Navigate to Plugins > Add New.
- Click Upload Plugin.
- Select the zip file downloaded in step 1.
- Click Install Now.
- Click Activate.
Next: Write your filter hook for your user ID custom dimension index.
Add a call to the cme_user_id_custom_dimension_index
filter hook to your child theme’s functions.php file. Change the custom dimension index to match the user ID custom dimension index in your Google Analytics property.
add_filter( 'cme_user_id_custom_dimension_index', function($custom_dimension_index) {
return '5'; // Change this to match your CD index number that's set in GA.
} );
This solution is based on Julius Fedorovicius’ article, HTML5 Video Tracking Recipe for Google Tag Manager posted on Analytics Mania.