Skip to content

Commit

Permalink
add AppsFlyer as amp-analytics vendor (#35610)
Browse files Browse the repository at this point in the history
* add analytics vendor appsflyer

* added amp.appsflyer.com and amp.onelink.me dns

* added appsflyer analytics vendor

* update doc link, params

* add OWNERS file

* add analytics vendor appsflyer

* added amp.appsflyer.com and amp.onelink.me dns

* added appsflyer analytics vendor

* update doc link, params

* add OWNERS file

* fix test

* Update extensions/amp-analytics/0.1/vendors/OWNERS

Co-authored-by: Alan Orozco <[email protected]>

Co-authored-by: Alan Orozco <[email protected]>
  • Loading branch information
fredsh2k and alanorozco authored Aug 11, 2021
1 parent 5fa2ca7 commit f062e8d
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 0 deletions.
54 changes: 54 additions & 0 deletions examples/analytics-vendors.amp.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<option>adobeanalytics_nativeConfig</option>
<option>alexametrics</option>
<option>amplitude</option>
<option>appsflyer</option>
<option>atinternet</option>
<option>afsanalytics</option>
<option>baiduanalytics</option>
Expand Down Expand Up @@ -285,6 +286,59 @@
</script>
</amp-analytics>

<!-- AppsFlyer example -->
<amp-analytics type="appsflyer" id="appsflyer">
<script type="application/json">
{
"vars": {
"webAppId": "c1e0b335-5b96-486e-8694-01c165df48d1"
},
"linkers": {
"enabled": true
},
"triggers": {
"subscribe": {
"on": "click",
"request": "event",
"selector": "#subscribeBtn",
"extraUrlParams": {
"data": {
"eventType": "EVENT",
"eventName": "subscribe_clicked"
}
}
},
"purchaseSuccess": {
"on": "amp-form-submit-success",
"request": "event",
"selector": "#purchaseForm",
"extraUrlParams": {
"data": {
"eventType": "EVENT",
"eventName": "purchase_success",
"eventRevenue": "${formFields[revenue]}",
"eventRevenueCurrency": "ILS",
"eventValue": "{'key0': 'value0', 'key1': 1}"
}
}
},
"login": {
"on": "click",
"request": "event",
"selector": "#loginSubmitButton",
"extraUrlParams": {
"data": {
"eventType": "IDENTIFY",
"customerUserId": "AUTHDATA(cuid)"
}
}
}
}
}
</script>
</amp-analytics>
<!-- End AppsFlyer example -->

<!-- AT Internet tracking -->
<amp-analytics type="atinternet" id="atinternet">
<script type="application/json">
Expand Down
4 changes: 4 additions & 0 deletions extensions/amp-analytics/0.1/test/vendor-requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"host": "https://api.amplitude.com?api_key=!apiKey&device_id=_client_id(amplitude_amp_id)_&library=amp%2F_amp_version_&time=_timestamp_&language=_browser_language_&user_agent=_user_agent_",
"event": "https://api.amplitude.com/amp/event?api_key=!apiKey&device_id=_client_id(amplitude_amp_id)_&library=amp%2F_amp_version_&time=_timestamp_&language=_browser_language_&user_agent=_user_agent_"
},
"appsflyer": {
"onelink": "https://amp.onelink.me/amp/v1/onelink?webAppId=!webAppId&afWebUserId=_cookie(afUserId)_&amp-afUserId=_client_id(amp-afUserId)_&amp-afRefUserId=_cookie(amp-afRefUserId)_",
"event": "https://amp.appsflyer.com/amp/v1/events?webAppId=!webAppId&afWebUserId=_cookie(afUserId)_&amp-afUserId=_client_id(amp-afUserId)_&amp-afRefUserId=_cookie(amp-afRefUserId)_"
},
"atinternet": {
"base": "https://!log.xiti.com/hit.xiti?s=!site&ts=_timestamp_&r=_screen_width_x_screen_height_x_screen_color_depth_&re=_available_screen_width_x_available_screen_height_",
"suffix": "&medium=amp&&ref=_document_referrer_",
Expand Down
15 changes: 15 additions & 0 deletions extensions/amp-analytics/0.1/vendors/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// For an explanation of the OWNERS rules and syntax, see:
// https://github.com/ampproject/amp-github-apps/blob/main/owners/OWNERS.example
{
rules: [
// Vendor file for appsflyer
{
pattern: 'appsflyer.json',
owners: [
{name: 'ampproject/wg-components'},
{name: 'AppsFlyer'},
{name: 'fredsh2k'},
],
},
],
}
62 changes: 62 additions & 0 deletions extensions/amp-analytics/0.1/vendors/appsflyer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"transport": {
"useBody": true,
"beacon": true
},
"requests": {
"onelink": "https://amp.onelink.me/amp/v1/onelink?webAppId=${webAppId}&afWebUserId=${afWebUserId}&amp-afUserId=${amp-afUserId}&amp-afRefUserId=${amp-afRefUserId}",
"event": "https://amp.appsflyer.com/amp/v1/events?webAppId=${webAppId}&afWebUserId=${afWebUserId}&amp-afUserId=${amp-afUserId}&amp-afRefUserId=${amp-afRefUserId}"
},
"triggers": {
"onelink": {
"on": "visible",
"request": "onelink",
"extraUrlParams": {
"data": {
"eventType": "LOAD"
},
"meta": {
"referrer": "${documentReferrer}",
"timestamp": "${timestamp}",
"userAgent": "${userAgent}",
"locationHref": "${ampdocUrl}"
}
}
},
"event": {
"on": "visible",
"request": "event",
"extraUrlParams": {
"data": {
"eventType": "LOAD"
},
"meta": {
"referrer": "${documentReferrer}",
"timestamp": "${timestamp}",
"userAgent": "${userAgent}",
"locationHref": "${ampdocUrl}"
}
}
}
},
"linkers": {
"enabled": true,
"proxyOnly": false,
"linker": {
"ids": {
"afRefUserId": "CLIENT_ID(amp-afUserId)"
}
}
},
"cookies": {
"enabled": true,
"amp-afRefUserId": {
"value": "LINKER_PARAM(linker, afRefUserId)"
}
},
"vars": {
"afWebUserId": "COOKIE(afUserId)",
"amp-afUserId": "CLIENT_ID(amp-afUserId)",
"amp-afRefUserId": "COOKIE(amp-afRefUserId)"
}
}
6 changes: 6 additions & 0 deletions extensions/amp-analytics/analytics-vendors-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ Adds support for Alexa Certified Site Metrics. The `atrk_acct` and `domain` vari

Type attribute value: `amplitude`

### AppsFlyer

Type attribute value: `appsflyer`

Adds support for AppsFlyer. More details for adding AppsFlyer support can be found at [appsflyer.com](https://support.appsflyer.com/hc/en-us/articles/360001610038#amp-support)

### AT Internet

Type attribute value: `atinternet`
Expand Down

0 comments on commit f062e8d

Please sign in to comment.