CXM_piwik.anubis 1.38 KB
/*
 * 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 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 String
  piwik_js_code
  (
    String       piwik_tracker,
    Int          site_id,
    List(String) piwik_domains
  )=
  "
    <!-- Piwik -->
    <script type=\"text/javascript\">
      var _paq = _paq || [];
      _paq.push([\"setDomains\", [" + concat(piwik_domains, ",") + "]]);
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u=\"//" + 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 -->
  ".