CXM_piwik.anubis
1.64 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Created by PyramIDE.
* User: Julien
* Date: 28/06/2016
* Time: 11:50
*
* Contain functions related to Piwik Analytics (Piwik 2.16.x)
*
* https://piwik.org/
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
read calexium_lib/web/CXM_making_a_web_site.anubis
read tools/basis.anubis
// this js code is to include in the <head> section of a webpage, it enable Piwik tracking for the given site/domains (Note: Only if the website was added to the Piwik tracker)
public define HTML_Head_Tag
piwik_js_code
(
String piwik_tracker,
Int site_id,
List(String) piwik_domains
)=
meta(literal(
"
<!-- Piwik -->
<script type=\"text/javascript\">
var _paq = _paq || [];
_paq.push([\"setDomains\", [" + concat(map((String domain) |-> "\"" + domain + "\"", piwik_domains), ",") + "]]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u=((\"https:\" == document.location.protocol) ? \"https\" : \"http\") + \"://" + piwik_tracker + "/\";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', \"" + site_id + "\" ]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src=\"//" + piwik_tracker + "/piwik.php?idsite=" + site_id + "\" style=\"border:0;\" alt=\"\" /></p></noscript>
<!-- End Piwik Code -->
")).