X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/26855add3861ad496efdcae8598ffdf7d1116074..c18e679be36b95fbf86a1dd5293d74ab70f6db4f:/app/assets/javascripts/piwik.js diff --git a/app/assets/javascripts/piwik.js b/app/assets/javascripts/piwik.js index d81a9ec63..19b5619a2 100644 --- a/app/assets/javascripts/piwik.js +++ b/app/assets/javascripts/piwik.js @@ -1,14 +1,19 @@ if (OSM.PIWIK) { $(document).ready(function () { 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) { }); } }); + + $("body").on("piwikgoal", function (e, goal) { + piwikLoader.done(function () { + piwikTracker.trackGoal(goal); + }); + }); }); }