How do I count plays of a video on my page?

Add a named event goal, then call postdeploy.track with that goal id when playback starts. A page goal counts the page load, not the play. Register the listener on DOMContentLoaded, because the snippet uses defer. Completions include every start, and one visit stores at most 20 goal events. A frame from another host does not fire your page's video events.

Last updated 26 November 2026. By Paul Badarau.

A fictional lesson page includes a video element. The author wants plays, not the number of people who opened the lesson. A page goal on the lesson path counts the load. It never counts the play, and it adds no pageview of its own.

  1. Ask an Owner or Administrator to add a named event goal. The id you will send is the event name, such as video_play. It has to be 1 to 40 characters, using lowercase letters, digits and underscores. The label shown in reports can be different, and the label can change later. The id cannot.
  2. Add the goal before the page calls it. If the id is not an active event goal, the collector rejects the event and stores nothing.
  3. The tracking snippet uses defer, so register the listener after deferred scripts have run. document.addEventListener('DOMContentLoaded', function () { var video = document.querySelector('video'); if (video) video.addEventListener('play', function () { window.postdeploy?.track('video_play'); }); }); The play event fires when playback starts.

Completion counts include repeats, so a second start on the same visit counts again. The daily rate is steadier. It divides visitor-days that completed the goal by all visitor-days in the same range and filters. A visit stores at most 20 goal events, and further goal events in that visit are not kept, so a page that records every start will stop adding them after 20.

A player drawn in a frame from another host is not your video element. The listener above never runs for it. Count a control that lives on your page, or call postdeploy.track from that host's own play callback, and take the callback's name from that host's documentation. The event carries the goal id and the page. It does not carry the visitor's name.

The product page for this is Analytics.

Start your 14-day free trial