开发者

Tracking marker clicks on Google Maps API - Analytics

开发者 https://www.devze.com 2023-04-08 19:05 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消