Repository navigation
Developer Guide Collecting Video and Ad Play Statistics
This guide is for developers who build their own player or app (mobile, smart TV, custom web player) on top of an AVideo site. It explains which requests to send so that video views, watch time and ad events appear in the AVideo reports.
Note: The AVideo website player already sends all of these requests. You only need this guide for your own player or app.
AVideo records:
- Video play statistics: views, the current position and the time watched. They feed the view counter, the watch-time reports and plugins such as VideosStatistics and MonetizeUsers.
- Ad play statistics: ad events (started, completed, skipped, clicked...). They feed the Video Ad Events Report.
In the examples, replace your-site.com with your site address.
Send a request:
- when the video starts playing,
- when it is paused,
- when it ends,
- every 30 seconds while it plays.
A seek is not a separate event: the next request simply carries the new position.
https://your-site.com/objects/videoAddViewCount.json.php
Method: POST, with normal form fields (application/x-www-form-urlencoded), not JSON.
| Parameter | Where | Description | Required | Example |
|---|---|---|---|---|
id |
POST field | The video ID | Yes | 4416 |
currentTime |
POST field | Current position in the video, in seconds | Yes | 120 |
seconds_watching_video |
POST field | Seconds actually watched since the previous request (do not count paused time) | Yes | 30 |
PHPSESSID |
URL query string | The viewer's session ID (see below) | Recommended | ea0ga3uh3ej0hdlplbs706nva3 |
user, pass
|
POST field | Username and password, so the view is linked to that user | No |
- The request must carry the site's session cookie. Without it the answer is
"msg": "Cookie is disabled"and nothing is recorded. Use a cookie jar: open any page of the site once (for example the video page), then send the statistics requests with the same cookies. Apps whose User-Agent containsAVideoMobileAppskip this check. -
PHPSESSIDis read only from the URL query string, not from the POST body. The JSON answer returns the currentsession_id; keep using it. - One view is counted per video per session. Later requests in the same session only update the position and watch time.
- Without
user/pass(or a logged-in session), the view is recorded but not linked to a user. - Bots are ignored, and each client is limited to 240 requests per minute.
curl -c cookies.txt -b cookies.txt \
-d "id=4416" -d "currentTime=120" -d "seconds_watching_video=30" \
"https://your-site.com/objects/videoAddViewCount.json.php?PHPSESSID=ea0ga3uh3ej0hdlplbs706nva3"For the first request use currentTime=0 and seconds_watching_video=0. When the video ends, send the final position and the seconds watched since the last request.
https://your-site.com/plugin/AD_Server/log.php
Method: POST (form fields). The events are stored in the tables of the AD_Server plugin, so AD_Server must have its tables installed (Admin Panel → Plugins → AD_Server → Install tables).
| Parameter | Description | Required | Example |
|---|---|---|---|
label |
The ad event name (see the list below) | Yes | AdStarted |
videos_id |
The ID of the video the ad played on | Yes | 4416 |
video_position |
Position in the video when the event happened, in seconds | Yes | 0 |
campaign_has_videos_id |
Only for AD_Server ads: the campaign video ID. Events with it count as "Own Videos" in the report, events without it as "Third Party Ads". | No | 12 |
user, pass
|
Username and password, so the event is linked to that user | No |
Requests sent with the HTTP Origin header https://imasdk.googleapis.com are ignored.
curl -b cookies.txt \
-d "label=AdStarted" -d "videos_id=4416" -d "video_position=0" \
"https://your-site.com/plugin/AD_Server/log.php"| Label | When to send it | Importance |
|---|---|---|
AdStarted |
The ad starts playing | Important |
AdFirstQuartile |
25% of the ad was played | Important |
AdMidpoint |
50% of the ad was played | Important |
AdThirdQuartile |
75% of the ad was played | Important |
AdCompleted |
The ad finished | Important |
AdSkipped |
The viewer skipped the ad | Important |
AdClicked |
The viewer clicked the ad | Important |
AdPaused |
The ad was paused | Optional |
AdResumed |
The ad resumed after a pause | Optional |
AdError |
The ad could not play | Optional |
AdMuted / AdUnmuted
|
The ad was muted / unmuted | Optional |
AdRewind |
The ad was rewound | Optional |
AdFullscreen / AdExitFullscreen
|
Fullscreen was entered / exited during the ad | Optional |
AdCreativeView |
The ad creative was shown | Optional |
AdAcceptInvitationLinear |
The viewer accepted a linear ad invitation | Optional |
AdCloseLinear |
A linear ad was closed | Optional |
Use exactly these names (they are case-sensitive): the report groups events by this text.
- Listen to the ad events of your ad SDK (for example the Google IMA SDK for Android or iOS).
- Map each event to one of the labels above.
- Send one request to
log.phpfor each event, withlabel,videos_idandvideo_position.
To get the ads themselves in an app, request the VMAP of a video through the API: https://your-site.com/plugin/API/get.json.php?APIName=vmap&videos_id=4416. See Different ad tags to serve different ads per app.
- Mobile apps: use the native player events (for example AVPlayer on iOS, ExoPlayer on Android) to know when to send the requests.
- Smart TVs: use the player events of each platform SDK (Roku, Amazon Fire TV...).
- Web players: see how the AVideo player does it in playerAdsEvents.js (ad events) and addView.js (views).
Start
Install and update
- Install on Ubuntu 24.04 or 26.04
- Installation Setup Page
- Scheduler cron job (required)
- Set up email
- Use HTTPS
- Own Encoder
- Docker
- Update AVideo
- Backup
- Server command-line tools
- Hidden configuration options
Videos
- Upload a video
- Local Encoder (on your computer)
- Bulk upload by FTP
- Import a channel
- Privacy options
- Only for logged-in users
- Resolutions by user group
- Storage options
- Move and protect video files
- Video does not play
Users
Live
- Make a live stream
- Stream with OBS
- Own live server
- One live server, many sites
- Live server install errors
- Live does not play
Plugins
Problems
Other
Old and retired guides