0

hey all i am trying to use Piwik in smartGWT to make some statistics the method i use is :

public static native void  PiwikReport(String email)/*-{
    window.alert("hello1");
    var pkBaseURL ="https://hpsmartplanner.com/piwik/piwik.js";
    var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
    piwikTracker.setCustomVariable(1,  "User Name",email , "page");
    piwikTracker.setCustomVariable(2,  "Type",  "Channel Partner" , "page");
    piwikTracker.setCustomVariable(3,  "Event",  "Signin" , "page");
    piwikTracker.trackPageView();
    window.alert("hello");
}-*/;

and in HTML file

   <!-- Piwik -->
    <script type="text/javascript" >
      var _paq = _paq || [];
      _paq.push(["trackPageView"]);
      _paq.push(["enableLinkTracking"]);

      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://hpsmartplanner.com/piwik/";
        _paq.push(["setTrackerUrl", u+"piwik.php"]);
        _paq.push(["setSiteId", "1"]);
        var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
        g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
      })();
    </script>
    <!-- End Piwik Code -->

it prints hello1 "the first alert" but it didn't print the second one

can any one please provide any help ? thanx.

mohammad
  • 2,142
  • 7
  • 35
  • 60
  • Your Piwik JavaScript has a `src` attribute. Remove that and check with [Piwik Tracking Code](http://piwik.org/docs/javascript-tracking/#toc-where-can-i-find-the-piwik-tracking-code). Also, in GWT JSNI, `window` and `document` are used as `$wnd` and `$doc`. Check [GWT Dev Guide - JSNI](http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html). – Sithsu Aug 29 '13 at 15:42
  • thanx @Sithsu i did and i removed the src from the piwik script and i put it in its own script but still i have the same problem – mohammad Aug 30 '13 at 15:51
  • Why do you need to load `piwik.js` yourself? Is that a JavaScript file you created with the name `piwik.js` or are you trying to load the `piwik.js` from Piwik itself? Because `piwik.js` from Piwik is automatically loaded (from `http(s)://hpsmartplanner.com/piwik/piwik.js`) by that JavaScript you embed. Also, update code block and remove `src` attribute. – Sithsu Aug 30 '13 at 16:45
  • thanx @Sithsu i did and i removed the src and i updated the code i also added piwik.js to the URL but it sayes **piwik is not defined** http(s)://hpsmartplanner.com/piwik/piwik.js – mohammad Aug 31 '13 at 06:09

0 Answers0