简体   繁体   中英

google maps markers with google analytics onclick event in variable

I've set up a site with a google map with markers. All the info (name, address, email, url) is entered by the editors of the website. http://oktamsterdam.nl/google-map-op-homepage/

To create markers I put all markerinfo in a variable

locaties = [
['Ouder- en Kindteam Centrum', '52.38022', '4.88348', '<h3>Ouder- en Kindteam Centrum</h3><a href="tel:0205555961"  onclick="ga(\x27send\x27, \x27event\x27, \x27Index\x27, \x27tel\x27, \x270205555961\x27);" >020 555 5961</a><br />Open: ma &#8211; vr van 8.30 – 17.00'],
['Ouder en Kindteam West', '52.37791', '4.84876', '<h3>Ouder en Kindteam West</h3><a href="mailto:bosenlommer@oktamsterdam.nl"  onclick="ga(\x27send\x27, \x27event\x27, \x27Index\x27, \x27mailto\x27, \x27bosenlommer@oktamsterdam.nl\x27);" >bosenlommer@oktamsterdam.nl</a><p>&nbsp;</p><a href="tel:0205555961"  onclick="ga(\x27send\x27, \x27event\x27, \x27Index\x27, \x27tel\x27, \x270205555961\x27);" >020 555 5961</a>']
];  

To make sure quotes and double quotes don't get mixed up I user \\x27, but the company that handles all Google Analytics tell me nothing is coming in (All 'normal' onclick event are, like

<a href="mailto:info@oktamsterdam.nl" onclick="ga('send', 'event', 'Index', 'mailto', 'info@oktamsterdam.nl');" >info@oktamsterdam.nl</a>

are)

Does anyone has a solution for this? Thanks in advance.

I have used single quote in my case and it works. You can follow this:

'<a href="' + url + '" onclick="_ga.push([\'track\', \'Download\', \'' + title + '\', \'format\']);">Download</a>';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM