AMP
Installation Instructions for TagCommander on AMP.
Accelerated Mobile Pages (AMP) use the Server-Side version of TagCommander.

AMP Definition

AMP, which stands for Accelerated Mobile Pages, is a technology issued from the open source Digital News Initiative (DNI) between Google and European publishers. AMP is a format allowing the creation of optimized mobile content in a bid to improve user experience.
If you wish to learn more about AMPs, click the following links:

Implementing Commanders Act on AMPs

AMP blocks synchronous JavaScript files called on your websites in order to increase mobile pages’ loading speed. For your Commanders Act container to be compatible, you need to adapt the way you set it up to be compliant with AMP’s requirements.
Below, you will find an example showing how to set up a Commanders Act container on your AMP pages. We recommend using the <amp-analytics> tag (https://www.ampproject.org/docs/reference/components/amp-analytics) to define your data layer and the container.
Important: This operation calls for Commanders Act’s API and thus requires that a server-side container be setup in Commanders Act’s user interface. To learn more about server-side set up please read the following article (https://community.commandersact.com/fr/introduction-au-tracking-server-side-avec-tagcommander/).

Setup example with analytics tag

1
<!doctype html>
2
<html amp lang=”en”>
3
<head>
4
<meta charset=”utf-8″>
5
<title>Commanders Act – AMP Analytics</title>
6
<link rel=”canonical” href=”http://example.ampproject.org/article-metadata.html” />
7
<meta name=”viewport” content=”width=device-width,minimum-scale=1,initial-scale=1″>
8
<!– Mandatory execution of the AMP Analytics Script “https://cdn.ampproject.org/v0/amp-analytics-0.1.js” –>
9
<script async custom-element=”amp-analytics”
10
src=”https://cdn.ampproject.org/v0/amp-analytics-0.1.js“></script>
11
<style>body {opacity: 0}</style><noscript><style>body {opacity: 1}</style></noscript>
12
<script async src=”https://cdn.ampproject.org/v0.js”></script>
13
</head>
14
<body
15
<amp-analytics id=”commandersact”>
16
<!– JSON data structure containing the TagCommander data layer –>
17
<script type=”application/json”>
18
{
19
“vars”: {
20
“tC_SiteID”: “3503”,
21
“tC_ContainerID”: “1”,
22
“env_template” : “homepage”,
23
“env_work” : “prod”,
24
“env_device” : “m”,
25
“env_country” : “IT”,
26
“page_name” : “amp_homepage”,
27
“user_id” : “”,
28
“user_newcustomer” : “”,
29
“order_id” : “”
30
},
31
<!– Call to Commanders Act’s API (server-side) –>
32
“requests”: {
33
“tC_BaseURL“: “//serverside${tC_SiteID}.tagcommander.com/${tC_ContainerID}/”,
34
<!– Page variables mentioned in the “tC_PageTrack” element –>
35
“tC_PageTrack“: “${tC_BaseURL}?&env_template=${template}&env_work=${work_environment}&env_device=${device}&env_country=${country}&page_name=${page_name}&user_id=${user_id}&user_newcustomer=${newcustomer}&order_id=${order_id}”,
36
<!– Event variables mentioned in the “tC_EventTrack” element. Note: “scroll” and other such variables are natively proposed in AMP pages–>
37
“tC_EventTrack“: “${tC_PageTrack}&scrollY=${scrollTop}&scrollX=${scrollLeft}&height=${availableScreenHeight}&width=${availableScreenWidth}&scrollBoundV=${verticalScrollBoundary}&scrollBoundH=${horizontalScrollBoundary}${eventLabel}”
38
},
39
<!– Additional parameters mentioned in the “extraUrlParams” element. Note: the clientId function creates a unique ID per visitor (different from the regular TCIDs)–>
40
“extraUrlParams”: {
41
“TCID_AMP”: “${clientId(TCID_AMP)}”,
42
“path”: “${ampdocUrl}”,
43
“type”: “${type|default:page}”,
44
“platform”: “AMP”,
45
“r”: “${random}”
46
},
47
<!– Execution of Commanders Act hits on the “triggers” element. “Pageview” sends the hit to the page viewed, the “clickPings” trigger sends the hit to an event defined in the “selector” –>
48
“triggers”: {
49
“pageview”: {
50
“on”: “visible”,
51
“request”: “tC_PageTrack”,
52
“vars”: {
53
“type”: “page”
54
}
55
},
56
“clickPings”: {
57
“on”: “click”,
58
“selector”: “.tC_events”,
59
“request”: “tC_EventTrack”,
60
“vars”: {
61
“type”: “event”
62
}
63
}
64
}
65
}
66
</script>
67
</amp-analytics>
68
<h1 id=”header”>AMP Page</h1>
69
<!– data-vars-event-label2 allows to collect additional variables, such as event variables –>
70
<span id=”event-test” class=”tC_events” data-vars-event-label2=”22″>
71
Click here to generate an event
72
</span>
73
</body>
Copied!
AMPs also allow you to set up your tag management tool through an iframe. Please note that if the iframe has not loaded within 5 seconds, it will not be called. You will find below an a setup example through an iframe:
Setup example with iframe
1
<!doctype html>
2
<html amp lang=”en”>
3
<head>
4
<meta charset=”utf-8″>
5
<title>Commanders ACT – Serverside – AMP Analytics</title>
6
<link rel=”canonical” href=”http://example.ampproject.org/article-metadata.html” />
7
<meta name=”viewport” content=”width=device-width,minimum-scale=1,initial-scale=1″>
8
<!– Mandatory execution of the AMP iframe script “https://cdn.ampproject.org/v0/amp-iframe-0.1.js ” –>
9
<script async custom-element=”amp-iframe” src=”https://cdn.ampproject.org/v0/amp-iframe-0.1.js”></script>
10
<style>body {opacity: 0}</style><noscript><style>body {opacity: 1}</style></noscript>
11
<script async src=”https://cdn.ampproject.org/v0.js”></script>
12
</head>
13
<body>
14
<!– Call to the TagCommander iframe “https://academy.commandersact.com/AMP/iframe.php” containing the data layer variables. Note: the iframe must belong to a different domain from that of the website (except if the allow-same-origin parameter is added) and be https –>
15
<amp-iframe width=1 height=1 src=”https://academy.commandersact.com/AMP/iframe.php? env_template=homepage&env_work=prod&env_device=m&env_country=IT&page_name=amp_homepage&user_id=&user_newcustomer=&order_id=” sandbox=”allow-scripts allow-same-origin” layout=”fixed” frameborder=”0″>
16
<!– Adding content to the iframe is mandatory (a pixel in this case)–>
17
<amp-img src=”https://academy.commandersact.com/AMP/pixel.gif” height=1 width=1 layout=”fill” placeholder></amp-img>25
18
</amp-iframe>
19
<h1 id=”header”>AMP Page</h1>
20
<span id=”event-test” class=”tC_events” data-vars-event-label2=”22″>
21
Click here to generate an event
22
</span>
23
</body>
24
</html>
Copied!
Last modified 2yr ago