Skip to content

AMP Analytics (pseudonymous measurement)

Attention

If you activate pseudonymous measurement via the INFOnline Measurement Manager, it is mandatory to have the standalone script integrated in Google AMP article.

For the measurement of accesses to AMP web pages (https://www.ampproject.org), a special Analytics tag (later in this chapter) is required, which must be supplemented by the respective site ID, the page code and a URL. The URL must point to a web page that contains a special SZM tag and must itself be delivered via HTTPS. This web page must be delivered via a different subdomain than the AMP web page and must be included in the locallist. No survey invitation ad (agof BFE) is delivered on AMP web pages.

Include in the header of the web page

<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>

Measurement of AMP web pages (pageview)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<amp-analytics type="infonline" id="infonline">
<script type="application/json">
{
 "vars": {
 "st": "site ID",
 "co": "comment",
 "cp": "code"
 },
 "requests": {.
 "url": "https://sub.example.com/amp-analytics-infonline.html"
 }
}
</script>
</amp-analytics>
Note

Please be careful not to insert additional line breaks and fill the variables ("vars") "st" and "cp" with their respective values:

st= Site ID
cp= Corresponding web page code
co= Comment (optional)

Please note that the "url" property must point to a subdomain of your choice and provide the content of the HTML web page shown in item 5 (below). The name of the HTML file is freely selectable.

Measurement of AMP Stories

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<amp-analytics type="infonline">
 <script type="application/json">
  {
   "vars": {
   "st": "site ID",
   "co": "comment",
   "cp": "code"
  },
   "requests": {.
     "url": "https://sub.example.com/amp-analytics-infonline.html"
  },
   "triggers": {
    "storyPageVisible": {
     }, "on": "story-page-visible",
     "request": "pageview"
     },
   }
 }
 </script>
</amp-analytics>
Note

Please be careful not to insert additional line breaks and fill the variables ("vars") "st" and "cp" with their respective values:

st= Site ID
cp= Corresponding web page code
co= Comment (optional)

Please note that the "url" property must point to a subdomain of your choice and provide the content of the HTML web page shown in item 5 (below). The name of the HTML file is freely selectable.

If you want to measure even more AMP story interactions such as calls to the "bookend" etc., you can find the corresponding documentation here. The only important thing is that the request must be of type "pageview".

Measurement of events (e.g. video playback)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<amp-analytics type="infonline">
 <script type="application/json">
  {
   "vars": {
   "st": "site ID",
   "co": "comment",
   "cp": "code"
   },
   "requests": {.
    "url": "https://sub.example.com/amp-analytics-infonline.html"
   },
   "triggers": {
    "myVideoPlay": {
     }, "on": "video-play",
     "selector": { "#myVideo",
     "request": { "event",
     "vars": {
      "ev": "play"
     }
   }
  }
 }
 </script>
</amp-analytics>
Note

Please be careful not to insert additional line breaks and fill the variables ("vars") "st" and "cp" with their respective values:

st= Site ID
cp= Corresponding web page code
co= Comment (optional)

Please note that the "url" property must point to a subdomain of your choice and provide the content of the HTML web page shown in item 5 (below). The name of the HTML file is freely selectable.

Please note that the specified selector for your video element has to be must be adapted by you.

Please make sure that the correct events are passed. For this you will find a corresponding mapping below:

AMP Video Event INFOnline Video Event
video-play play
video-pause pause
video-ended sple

Special HTML web page with SZM tag

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
< !DOCTYPE html>
< html>
<head>
  <script src=https://script.ioam.de/iam.js></script>
</head>
<body>
<script>
  var match,
      pl = /\+/g,
      search = /([^&=]+)=?([^&]*)/g,
      decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
      query = window.location.search.substring(1);
  var params = {};
  while (match = search.exec(query)) {
    params[decode(match[1])] = decode(match[2]);
  }
  if (params.type === 'event') {
    iom.i(params, 2);
    iom.e(params.ev);
  } else {
    iom.c(params, 2);
  }
</script>
</body>
</html>
Note

Please do not modify the source code shown above. Changes will inevitably result in your AMP integration not measuring up.

AMP Integration with TCF 2.0

Prerequisite

For the integration of a TCF 2.0-compliant CMP in interaction with AMP and INFOnline Measurement pseudonymous, it must be checked in advance whether the publisher is using a CMP, is also supported by AMP. If this is not the case, TCF 2.0 cannot be processed automatically. In addition, the publisher should always use the latest version of AMP. In addition, the following iframe content should be hosted by the publisher on a sub-domain of the Digital site:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<!DOCTYPE html>
<html lang="en">
<head>
  <script src="//script.ioam.com/iam.js?m=1"></script>
  <title>INFOnline AMP integration</title>
</head>
<body>
  <script src="//script.ioam.com/amp.js?m=1"></script>
</body>
</html>

Integration

For TCF 2.0 integration, the publisher needs the custom element <amp-consent> and must implement it according to the CMP vendor's specifications (here an example with Consent Manager):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<amp-consent id="ConsentManager" layout="nodisplay" type="ConsentManager">
  <script type="application/json">
    {
      "}, "postPromptUI",
      "clientConfig": {
        "id": "...Your CMP ID...",
        "params": ""
      }
    }
  </script>
  <div id="postPromptUI">
    <button on="tap:ConsentManager.prompt()" role="button">Manage privacy settings</button>
  </div>
</amp-consent>

Then, all that remains is to declare the custom element <amp-analytics> appropriately in a slightly modified form for regular inclusion

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<amp-analytics data-block-on-consent type="infonline" id="infonline">
  <script type="application/json">
  {
    "vars": {
      "st": "site ID",
      "co": "comment",
      "cp": "code"
    },
    "requests": {.
      "url": "https://sub.example.com/amp-analytics-infonline.html"
    }
  }
  </script>
</amp-analytics>
Note

The HTML attribute data-block-on-consent is used to control when a measurement is triggered. The measurement pulse is only triggered once the CMP has detected a positive consent decision.

Please note that only TCF 2.x compliant CMPs from the list are supported in Google AMP. Manual consent transmission is not possible in this environment.


Last update: May 10, 2023