How can I view which markers are being clicked on by users in Leaflet?


A few options

  1. You could build your own server end-point that registers a new database record each time a marker is clicked, including whatever information you want to track

  2. You could use Google Analytics and jQuery and do something like:

    var marker = L.marker([51.5, -0.09]).addTo(map);
    marker.on('click', function() {
       // sends notification to your Google Analytics account
       ga('send', 'event', 'marker', 'click', 'my marker');

    you would need more customization than shown here to track specific markers.

    Google Analytics event tracking: https://developers.google.com/analytics/devguides/collection/analyticsjs/events

  3. There is a service called maptiks that was built for map tracking and analytics: http://get.maptiks.com/maptiks-v1 https://www.sparkgeo.com/projects/maptiks

    I've never used this, so I can't say more than that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.