Jump to content

Adding onclick event stops phone number loading on mobile


wilsonf1

Recommended Posts

HeyI have a mobile version of my website and on one page I display a telephone number. When people click this number on their mobile phone device, it loads the number into the "make call" application. Pretty simple thing built into most mobile devices.I thought of adding an onclick event to the number to track this in google analytics - but when ever I try either onclick, or a jquery bind/click, it does track, but the number doesn't load in the call application on mobiles any more.It's like the javascript is overriding the default event - which is obviously no good!I've tried things like return TrackFunction() and tried return false and true but to no availCan anyone suggest something else to try to stop the 2 things from conflicting?Cheers

Link to comment
Share on other sites

you should post the code, but are you also returning true/false from your function too?i.e.

TrackFunction(){  .  .  return true;};..<a href="return TrackFunction()">Click</a>

Link to comment
Share on other sites

you should post the code, but are you also returning true/false from your function too?i.e.
<p style="text-align:center" class="phone-number" onclick="java script:return trackNum();">0800 000 123</p>

	function trackNum() {		_gaq.push(['_trackPageview', '/number-click/this-page/mobile']);		return true;		}

Link to comment
Share on other sites

can you check for errors in the mobile web browser?
Hmm no i cant, its the default htc one. I can obviously check the mobile version in a pc browser though. When i click the number i see in the status bar the call to google analytics - so my function is all goodIts just seems to interefer with the default behavior of clicking a number on a mobile
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...