add piwik tracking code to the system

João Reis

Member
Is there a global HEADER / FOOTER that I can add piwik tracking system code?
I want to track users behavior from register new account form to inside the system.
Thanks.
 
Code:
<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//analytics.intesys.com.br/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', '11']);
    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>
<!-- End Piwik Code -->
 
@João Reis - in the apps folder, you have a file called init.php. In same folder, create a file called init-custom.php and put this in it:
PHP:
<?php

Yii::app()->hooks->addAction('after_opening_body_tag', function($controller) {
    ?>
    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u="//analytics.intesys.com.br/";
        _paq.push(['setTrackerUrl', u+'piwik.php']);
        _paq.push(['setSiteId', '11']);
        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>
    <!-- End Piwik Code -->
    <?php
});
Save the file and visit the site, you'll now have the code in the page.
 
Just a question, to add my logo and some custom text in the registration page, is there a dynamic way to do that or just editing register.php?
Thanks.
 
I'm getting "Using $this when not in object context in /var/www/clients/client1/web132/web/apps/init-custom.php:46" when trying to use this example, line 46 is:

PHP:
$form = $this->beginWidget('CActiveForm');

I see that I need to learn about Yii framework and mailwizz design for deeper changes, but can you point me some light?

Thanks in advance.
 
Back
Top