Tracking marker clicks on Google Maps API - Analytics
I'm trying to track the amount of people clicking on map markers with google Analytics, is this possible and if so, what are my options?
Thanks in advan开发者_StackOverflow中文版ce!
The updated GA implementation is the following:
ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
Example:
google.maps.event.addListener(marker, 'click', function() {
ga('send', 'event', 'Videos', 'play', 'Fall Campaign');
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
I don't know why this isn't better documented but here's how I got it to work in the end. Add gaq.push to the addListener function for the marker click. See the documentation linked by antyrat.
google.maps.event.addListener(marker, 'click', function() {
gaq.push(['_trackEvent', 'category', 'action', 'opt_label']);
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
You can do this using Event Tracking functionality at Google Analytics. More about tracking system you can find at official documentation.
精彩评论