Marfeel tracks AMP page views with the native amp-analytics
element.
Add AMP Analytics
If are not already using amp-analytics
in your pages, add the following script tag in the head
of all your pages that Compass should track.
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
This script must be present only once in your AMP pages. If you already have it, don’t add it again.
Enable Compass in AMP pages
Initialize the amp-analytics in the <body>
of your AMP pages ensuring your unique account ID is correctly added before /* AccountId */
:
<amp-analytics config="https://events.newsroom.bi/amp.v1.json" data-credentials="include">
<script type="application/json" >
{
"vars" : {
"accountId": "/* AccountId */"
}
}
</script>
</amp-analytics>
ßeta: AMP tracker v.2.0
v.2.0-beta adds full support to track CMP metrics and Private sessions on AMP to have full visibility on your audience. The idea is to be able to remove the block-on-consent
from amp-analtyics
.
Doing so will correctly track the Consent Choice in AMP with values Accepted, Rejected, No CMP & No Choice.
Note the change on the config
attribute from v1.json
to v2.json
<amp-analytics config="https://events.newsroom.bi/amp.v2.json" data-credentials="include">
<script type="application/json" >
{
"vars" : {
"accountId": "/* AccountId */"
}
}
</script>
</amp-analytics>
Duet to amp-analytics and amp-consent constraints, Marfeel monitors consent choices through a default 5-second timeout:
- If the user accepts or rejects the consent before this timeout the user will be classified:
- Accept:
User loyalty = new
andconsent choice = Accepted
- Reject:
User loyalty = private
andconsent choice = Rejected
- Accept:
- If the timeout triggers:
User loyalty = private
&consent choice = No Choice
- If the user later accepts or rejects both
User Loyalty
andconsent choice
will be modified accordingly.
In the aggregated Explore reports, when a session is first tracked as private
(due to no choice) and then as new
(after being accepted), the user will be counted if they are grouped by “Visitor loyalty” in both the New and Private groups. However, they will only be counted once in the total count.
By default the timeout is set to 5s. It can be customized via a url queryparam
https://events.newsroom.bi/amp.v2.json?timeout=10
Things to bear in mind when modifying the default timeout:
- If you increase the timeout, sessions that last less than the indicated timeout won’t be tracked at all.
- If you decrease the timeout, sessions will double count as explained above on grouped Explore reports.
Ads in Amp
In order to properly track the ads is recommended to add the parameter data-vars-ad-slot
to the amp-ad with its slotname
information.
<amp-ad width="300" height="250" type="foo" data-vars-ad-slot="SLOTNAME">
<div placeholder>Loading ...</div>
</amp-ad>
Custom Page Technology
On AMP you can override the default pageType
adding a var directly on the Marfeel snippet:
<amp-analytics config="https://events.newsroom.bi/amp.v1.json" data-credentials="include">
<script type="application/json" >
{
"vars" : {
"accountId": "/* AccountId */"
},
"extraUrlParams": {
"pageType": 3
}
}
</script>
</amp-analytics>
Infinite scroll using amp-next-page
You can add utm_pp
parameter with the previous URL (encoded) along with utm_cpm_rs=amp-page-next
. For example:
https://www.marfeel.com/destination-url.html?utm_cmp_rs=amp-next-page&utm_pp=https%3A%2F%2Fwww.marfeel.com%2Fprevious-url.html