简体   繁体   中英

Track href=tel: link

I have a button in my email with <a href="tel:123456"> link, so mobile users can dial my number with only a click on the button.

Is there a way to track the clicks on this button? eg link to a php file which will do the tracking; but I have no idea how to redirect or what to return to the mobile device.

I got it without any JavaScript. Very easy and pure PHP:

header("Location: tel:+123456789");

Tested on Android 2.x, 4.x and BlackBerry 6.0 I will test it on the IPhone on monday and report back if it won't work. (But I'm 99.99% sure it will work.)

Edit: Its working fine on iOS 5.1, 6.0 and 7.0!

You could use a bit of JavaScript to trigger the call. Add a link to a PHP file that tracks the click and put this in that PHP file:

window.open('tel:123456', '_top');

Here is one possibility: if I've not completely misunderstood this possibly related StackOverflow question , you're actually allowed to simulate a click() on a <a href="tel:..."</a>..</a> using JavaScript.

Using this technique, you might change your "call me" link in your E-Mail signature to redirect to a server hosting something along the lines of (it really would be this simple, besides HTML scaffolding of course):

<script>window.location.href = "tel:123456";</script>

The two caveats with this concept are that

  1. The user must have network connectivity at that exact moment for the call to go through
  2. The user will leave whatever environment they use for email, their web browser will momentarily flash onto the screen, then they'll enter their phone's dialler.

At the most simplistic, you could track your Web server's access logs. At the other end of the spectrum, using say Google Analytics may be blocked on certain devices (perhaps by the MVPS hosts file ).

I have one other idea, but the following is an entirely experimental hypothesis; if it seems to work, test it everywhere , then test it everywhere else , before using it! :P

<a href="data:text/html;base64,PHNjcmlwdD53aW5kb3cubG9jYXRpb24uaHJlZj0idGVsOjEyMzQ1NiI7PC9zY3JpcHQ+Cg==">Call me!</a>

The above is the base64 -encoded string "window.location.href = "tel:123456""; I encoded it to be able to use < and > inside the href .

You can get the href value as:

<a class="phone" href="tel:123456">

<script>
$(".phone").click(function (){
var url=$this.attr('href');
var str=url.split(":");
alert(str[1]);
return false;
});
</script>

You will get the phone number from url.

The easiest way would be for you to simply use a link shortening/tracking service like bit.ly. They can track the clicks for you. As far as functionality goes (making it auto dial your phone number after clicking), try putvande's suggestion.

If you have trouble triggering the phone call automatically, you might be better looking into call forwarding services. Maybe a Google number or something might work? Not sure what automated phone services are out there, but they surely would have some way of tracking the forwards.

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