New home › Forums › Basic Version › General queries › HowTo – marker visit/click statistics using Google Analytics
- This topic has 5 replies, 4 voices, and was last updated 1 year, 4 months ago by Matthew.
-
AuthorPosts
-
July 18, 2021 at 11:22 pm #69915mfoltinMember
Hi, this is not a question but rather a HowTo for others in case they’ll also have similar business requirement like I did. Might save you few hours of analyzing the options 🙂
I needed to implement some marker viewing/opening statistics in order to observe, which markers are more popular than the others etc. I knew it had to be implemented within the Custom JS code section within the “infowindowopen” event listener, but I did not know how to transfer that information to my database. First I was thinking I needed an extra REST service to be called from jQuery, but yesterday I received a great tip and it works so I decided to share it with you… I just interconnected the mentioned listener with Google Analytics and now I can nicely observe it in my Google Analytics Console!
So just in case you need similar functionality, just add this code to your custom JS section within the WP Google Maps plugin (beforehand you have to add GA to your website – see https://developers.google.com/analytics/devguides/collection/analyticsjs):
jQuery(function ($) { $(window).on("infowindowopen.wpgmza", function (event) { var marker = event.target.feature; ga('send', { hitType: 'event', eventCategory: 'Marker', eventAction: 'Open', eventLabel: marker.id + ' ' + marker.title }); }); });
Good luck!
PS: I had a problem with the free version of MonsterInsights plugin, which was blocking the events sent directly to GA. Had to deactivate it and add the Google Analytics support manually using the “Insert Headers and Footers” WP plugin.
July 19, 2021 at 10:39 am #69925MatthewModeratorHi there,
Thank you so much for posting and sharing this information on the forum, we really appreciate it!
We are happy that you have found a solution for your needs and that it is working great.
We hope that you are enjoying WP Google Maps and that it is serving you well!
Kindest Regards
MatthewApril 27, 2022 at 4:42 am #72939luceinMemberDo you have information on how to get this working with the new Google Analytics v4?
I tried this above and I can see the event trigger in the browser console. But I am not seeing the event show up in Universal Analytics or the new GA4.
Do you have a setup guide to get analytics working with wpgmaps? or an addon for analyics?
My customer wants to track which dealers are clicked on the most in the map and in the list.
please advise.
Doug- This reply was modified 1 year, 4 months ago by lucein.
April 27, 2022 at 6:01 pm #72949MatthewModeratorHi Doug,
Thank you for getting back in touch, we do appreciate your time.
Unfortunately we currently do not have any analytics features for WP Google Maps, however, we may look into this in the future.
We do apologize for any inconvenience this may have caused.
Kindest Regards,
MatthewMay 11, 2022 at 12:31 pm #73048NimbblParticipanthi
May 12, 2022 at 10:09 am #73069MatthewModeratorHi @Nimbbl,
How may we help?
Kindest Regards,
Matthew -
AuthorPosts
- You must be logged in to reply to this topic.