X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/4d91fe3dd95c1058cb8d24fd4c900223e30b9059..16da03aacb264c1703d8bd4fab5c58c78745be00:/app/assets/javascripts/piwik.js?ds=inline diff --git a/app/assets/javascripts/piwik.js b/app/assets/javascripts/piwik.js index d0443ae6d..19b5619a2 100644 --- a/app/assets/javascripts/piwik.js +++ b/app/assets/javascripts/piwik.js @@ -1,14 +1,19 @@ -if (OSM.PIWIK_LOCATION && OSM.PIWIK_SITE) { +if (OSM.PIWIK) { $(document).ready(function () { - var base = document.location.protocol + "//" + OSM.PIWIK_LOCATION + "/"; + var base = document.location.protocol + "//" + OSM.PIWIK.location + "/"; + var piwikTracker; - $.ajax({ + var piwikLoader = $.ajax({ url: base + "piwik.js", dataType: "script", cache: true, success: function () { - var piwikTracker = Piwik.getTracker(base + "piwik.php", OSM.PIWIK_SITE); + piwikTracker = Piwik.getTracker(base + "piwik.php", OSM.PIWIK.site); + if (OSM.user) { + piwikTracker.setUserId(OSM.user.toString()); + } + piwikTracker.trackPageView(); piwikTracker.enableLinkTracking(); @@ -17,5 +22,11 @@ if (OSM.PIWIK_LOCATION && OSM.PIWIK_SITE) { }); } }); + + $("body").on("piwikgoal", function (e, goal) { + piwikLoader.done(function () { + piwikTracker.trackGoal(goal); + }); + }); }); }