ampproject / ampproject/amphtml

Improve <amp-analytics type="googleanalytics" default configuration

Open
#26,808 3 comments 0 reactions 0 assignees View on GitHub
Component: amp-analytics Stale Type: Feature Request WG: analytics
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

## Describe the new feature or change to an existing feature you'd like to see

https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/0.1/vendors/googleanalytics.json provides basic default configuration. But, it looks like it can be improved to provide 'basic' minimal configuration.

1. For `pageview`, it is having `requests`, but not `triggers`. I think, below default `triggers` or better can be included by default:
```json
"triggers": {
"default pageview": {
"on": "visible",
"request": "pageview",
"vars": {
"title": "${title}" // OR URL?? OR Not needed?
}
}
```
2. Similarly for `social`:
```json
"triggers": {
"tweetClick" : {
"on": "click",
"selector": 'a[href*="twitter.com/share"], a[href*="twitter.com/intent"]',
"request": "social",
"vars": {
"socialNetwork": "twitter",
"socialAction": "tweet",
"socialTarget": "${ampdocUrl}"
}
}

"triggers": {
"fbShareClick" : {
"on": "click",
"selector": 'a[href*="facebook.com/sharer"]',
"request": "social",
"vars": {
"socialNetwork": "facebook",
"socialAction": "share",
"socialTarget": "${ampdocUrl}"
}
}

```

## Reasons

1. Minimal default setup can avoid unnecessary handcoding (sometimes wrong) configurations. For example, may refer to Economic Time's AMP version (Indian Newspaper site)
2. In case of `pageview`, `triggers` is missing. If someone is not too technical, may completely miss it.

## Additional context

Coming from #26691

Contributor guide

Open the contributing guide

Research direction

Start with extensions/amp-analytics/0.1/vendors/googleanalytics.json and review the related context in issue #26691. Compare the proposed pageview and social defaults with the existing vendor configuration and determine the intended minimal behavior. Done means the agreed default configuration is represented consistently in that file and its behavior is validated.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
analytics
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.