ampproject / ampproject/amphtml

documentExit only affects 17% of the traffic

Open
#36,960 1 comment 0 reactions 0 assignees View on GitHub
P3: When Possible Stale Type: Bug WG: analytics
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### Description

I have a custom analytics provider that basicly has a timer and a documentExit event, like:

```
{
"requests": {
"event": "https://foo.com/ping?rand=RANDOM"
},
"triggers": {
"pageTimer": {
"on": "timer",
"timerSpec": {
"interval": 10,
"maxTimerLength": 1800
},
"request": "event",
"vars": {
"eventId": "timer",
"pageViewId64": "PAGE_VIEW_ID_64",
"version": 0.2
},
"extraUrlParams": {
"ac": "${accountId}",
"uid": "${clientId(foo_uid)}",
"l": "${totalEngagedTime}",
"sc_h": "${scrollHeight}",
"sc_t": "${scrollTop}",
"url": "${ampdocUrl}",
"c": "${canonicalUrl}",
"t": "${navTiming(navigationStart)}",
"ps": "${navTiming(navigationStart)}",
"amp_p": "${pageViewId64}",
"dr": "${documentReferrer}",
"r": "${externalReferrer}",
"n": "${timestamp}",
"amp": "true",
"v":"${version}",
}
},

"pageEnd": {
"on": "visible",
"request": "event",
"visibilitySpec": {
"reportWhen": "documentExit"
},
"vars": {
"eventId": "timer",
"pageViewId64": "PAGE_VIEW_ID_64",
"version": 0.2
},
"extraUrlParams": {
"ac": "${accountId}",
"uid": "${clientId(foo_uid)}",
"l": "${totalEngagedTime}",
"sc_h": "${scrollHeight}",
"sc_t": "${scrollTop}",
"url": "${ampdocUrl}",
"c": "${canonicalUrl}",
"t": "${navTiming(navigationStart)}",
"ps": "${navTiming(navigationStart)}",
"amp_p": "${pageViewId64}",
"dr": "${documentReferrer}",
"r": "${externalReferrer}",
"n": "${timestamp}",
"amp": "true",
"v":"${version}",
"pvar[lastEvent]": "true",
"le": "1"
}
}

},
"transport": {
"beacon": true,
"xhrpost": true,
"image": false
}
}

```

The results of the data I recieved are very poor in terms that just 12//17% of the traffic (depending on the browser) are sending the documentExit event. It's this a known issue? There is an alternate way to do this? I've tried with `hidden` instead of `visible` and `documentExit` with similar results.

### Reproduction Steps

This bug its relative to big data percentages not being able to reproduce it on a one to one basis.

### Relevant Logs

```shell
Chrome,Mobile, 17%
Safari,Mobile, 14%
SamsungBrowser,Mobile, 6%
Chrome,Desktop, 11%
..
```

### Browser(s) Affected

_No response_

### OS(s) Affected

_No response_

### Device(s) Affected

_No response_

### AMP Version Affected

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.