-
Notifications
You must be signed in to change notification settings - Fork 979
Developer Guide: Collecting Video and Ad Play Statistics
I understand. Below is an updated version that provides guidance for developers to build similar functionality for collecting video and ad play statistics on their apps, based on the AVideo model. This guide focuses on the structure and logic required so developers can adapt the solution to different environments such as mobile apps or Smart TVs.
This guide provides developers with instructions for accurately collecting and sending video and ad play statistics to AVideo, helping generate reliable reports on user interactions and ad performance.
AVideo tracks:
- Video Play Statistics: Monitors when videos start and end, and logs viewing duration. Requests should be sent every 30 seconds while the video is playing to log progress.
- Ad Play Statistics: Captures events and interactions with ads for detailed reporting.
For video tracking, developers must capture two key events:
- Play Event: When the video starts.
- End Event: When the video finishes.
Additionally, while the video is playing, a request should be sent every 30 seconds to log the current progress. The logged seconds_watching_video
should only count if the video is actively playing; if paused or stopped, it should not accumulate.
URL: {webSiteRootURL}/objects/videoAddViewCount.json.php
Parameter | Description | Required | Example |
---|---|---|---|
id |
The unique ID of the video being watched. | Yes | 4416 |
currentTime |
The current position in the video (in seconds). | Yes | 120 |
seconds_watching_video |
Duration watched since the last log (in seconds). | Yes | 30 |
PHPSESSID |
The PHP session ID, identifying the user's session. | Yes | ea0ga3uh3ej0hdlplbs706nva3 |
user |
The username for authentication. | No | username |
pass |
The password or token for authentication. | No | userpassword |
1. Initial Play Event When the video starts:
POST {webSiteRootURL}/objects/videoAddViewCount.json.php
{
"id": "4416",
"currentTime": "0",
"seconds_watching_video": "0",
"PHPSESSID": "ea0ga3uh3ej0hdlplbs706nva3",
"user": "username",
"pass": "userpassword"
}
2. Progress Tracking (Every 30 Seconds) While the video is playing:
POST {webSiteRootURL}/objects/videoAddViewCount.json.php
{
"id": "4416",
"currentTime": "120",
"seconds_watching_video": "30",
"PHPSESSID": "ea0ga3uh3ej0hdlplbs706nva3",
"user": "username",
"pass": "userpassword"
}
3. End Event When the video ends:
POST {webSiteRootURL}/objects/videoAddViewCount.json.php
{
"id": "4416",
"currentTime": "600",
"seconds_watching_video": "600",
"PHPSESSID": "ea0ga3uh3ej0hdlplbs706nva3",
"user": "username",
"pass": "userpassword"
}
To build a similar feature for mobile apps or Smart TVs:
-
Set Up Tracking:
- Use native APIs to monitor the play state of the video (e.g., AVPlayer for iOS, ExoPlayer for Android, or specific SDKs for Smart TVs).
- Track events like
play
,pause
,seek
, andend
using platform-specific event listeners.
-
Create a Timer for Interval Tracking:
- Use a timer that runs every 30 seconds to log the video’s current position and the duration watched (
seconds_watching_video
). - Make sure the timer increments
seconds_watching_video
only if the video is actively playing.
- Use a timer that runs every 30 seconds to log the video’s current position and the duration watched (
-
Structure the API Call:
- On each interval, send an HTTP POST request to the AVideo endpoint (
videoAddViewCount.json.php
), passing the video ID, current time, and watching duration. - Ensure that the user’s session ID (
PHPSESSID
),user
, andpass
parameters are included for authentication.
- On each interval, send an HTTP POST request to the AVideo endpoint (
- If the
user
andpass
parameters are not provided, the system will still log the event, but it will not identify the user who watched the video.
URL: {webSiteRootURL}/plugin/AD_Server/log.php
Parameter | Description | Required | Example |
---|---|---|---|
label |
The type of ad event (e.g., AdStarted , AdMidpoint ). |
Yes | AdStarted |
videos_id |
The ID of the video associated with the ad. | Yes | 4416 |
video_position |
The timestamp in the video when the ad event occurred. | Yes | 0.00 |
user |
The username for authentication. | No | username |
pass |
The password or token for authentication. | No | userpassword |
POST {webSiteRootURL}/plugin/AD_Server/log.php
{
"label": "AdStarted",
"videos_id": "4416",
"video_position": "0.00",
"user": "username",
"pass": "userpassword"
}
Label | Description | Importance |
---|---|---|
AdStarted |
When an ad starts playing. | Important |
AdFirstQuartile |
When the ad reaches 25% completion. | Important |
AdMidpoint |
When the ad reaches 50% completion. | Important |
AdThirdQuartile |
When the ad reaches 75% completion. | Important |
AdCompleted |
When the ad finishes playing. | Important |
AdPaused |
When the ad is paused. | Optional |
AdResumed |
When the ad resumes after a pause. | Optional |
AdSkipped |
When the ad is skipped. | Optional |
AdClicked |
When the ad is clicked by the user. | Optional |
AdError |
When an error occurs during ad playback. | Important |
To track ad events on different platforms:
-
Monitor Ad Events:
- Use ad-specific APIs provided by the platform (e.g., Google IMA SDK for mobile apps) to listen for ad events like
AdStarted
,AdCompleted
, etc.
- Use ad-specific APIs provided by the platform (e.g., Google IMA SDK for mobile apps) to listen for ad events like
-
Log Events:
- Structure the data to match the AVideo API parameters (
label
,videos_id
,video_position
). - Make API calls to the endpoint (
AD_Server/log.php
) whenever a relevant ad event occurs.
- Structure the data to match the AVideo API parameters (
-
Handle Authentication:
- Ensure that the
PHPSESSID
,user
, andpass
parameters are included in the request for proper logging.
- Ensure that the
- If
user
andpass
are not provided, the system logs the event but does not identify the user who interacted with the ad.
To ensure consistent behavior across all devices and platforms:
- Mobile Apps: Implement the API calls and tracking logic using native video player APIs (e.g., AVPlayer for iOS and ExoPlayer for Android).
- Smart TVs: Utilize SDKs specific to each platform (e.g., Roku, Amazon Fire TV) to implement tracking logic.
- Web Players: Follow the JavaScript guidelines as detailed in the AVideo JS event tracking guide.