javascript - Google Maps trigger Google Analytics Events wen map controls are used -
how fire google universal analytics events every time google maps (v3) controls used: zoom in, zoom out, terrain, satellite, street view...
this standard universal analytics event:
ga('send', 'event', 'event category', 'event action', 'event label');
you'd need add standard google maps event listeners following on map:
- zoom_changed
- maptypeid_changed
e.g.
function doyouranalytics(event) { // or whatever need call here ga('send', 'event', 'event category', event, 'event label'); } map.addlistener('zoom_changed', function() { doyouranalytics('zoom_changed'); }); map.addlistener('maptypeid_changed', function() { doyouranalytics('maptypeid_changed'); });
you don't give indication want 'event category', 'event action', 'event label', can pass event data need function. e.g. zoom maybe want check map's current zoom level, work out if they'd zoomed in or out, , specify event label.
Comments
Post a Comment