/cme-ga4html5vid

WordPress plugin for tracking HTML5 video events in Google Analytics.

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

cme-ga4html5vid

A WordPress Plugin for HTML5 Video Tracking using Google Analytics (UA)

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.


Install

  1. Download the latest release (zip file) from GitHub.
  2. Log in to your WordPress site as an admin.
  3. Navigate to Plugins > Add New.
  4. Click Upload Plugin.
  5. Select the zip file downloaded in step 1.
  6. Click Install Now.
  7. Click Activate.

Next: Write your filter hook for your user ID custom dimension index.

PHP Filter Hook

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.
} );

Screen Captures

Google Analytics Realtime HTML5 Video Events Report

Google Analytics Realtime HTML5 Video Events Report

Google Analytics Custom Report Showing HTML5 Video Events by User ID

Google Analytics Custom Report Showing HTML5 Video Events by User ID


Credits

This solution is based on Julius Fedorovicius’ article, HTML5 Video Tracking Recipe for Google Tag Manager posted on Analytics Mania.