简体   繁体   English

跟踪href = tel:链接

[英]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. 我的电子邮件中有一个带有<a href="tel:123456">链接的按钮,因此移动用户只需单击该按钮即可拨打我的电话号码。

Is there a way to track the clicks on this button? 有没有办法跟踪此按钮的点击? eg link to a php file which will do the tracking; 例如,链接到将进行跟踪的php文件; but I have no idea how to redirect or what to return to the mobile device. 但我不知道如何重定向或返回到移动设备。

I got it without any JavaScript. 我没有任何JavaScript。 Very easy and pure PHP: 非常简单和纯净的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. 我已经在Android 2.x,4.x和BlackBerry 6.0上进行了测试,我将在周一在iPhone上进行测试,如果无法正常工作,请向我报告。 (But I'm 99.99% sure it will work.) (但是我有99.99%的把握会成功。)

Edit: Its working fine on iOS 5.1, 6.0 and 7.0! 编辑:它可以在iOS 5.1、6.0和7.0上正常工作!

You could use a bit of JavaScript to trigger the call. 您可以使用一些JavaScript来触发调用。 Add a link to a PHP file that tracks the click and put this in that PHP file: 将链接添加到跟踪点击的PHP文件,并将其放入该PHP文件:

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. 这是一种可能性:如果我没有完全误解这个可能相关的StackOverflow问题 ,实际上可以让您在<a href="tel:..."</a>..</a> a <a href="tel:..."</a>..</a>上模拟click() <a href="tel:..."</a>..</a>使用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): 使用这种技术,您可以更改电子邮件签名中的“打电话给我”链接,以重定向到承载以下内容的服务器(实际上很简单,当然还有HTML支架):

<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. 最简单的是,您可以跟踪Web服务器的访问日志。 At the other end of the spectrum, using say Google Analytics may be blocked on certain devices (perhaps by the MVPS hosts file ). 另一方面,在某些设备上(例如MVPS主机文件可能会阻止使用Google Analytics(分析)。

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 :P

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

The above is the base64 -encoded string "window.location.href = "tel:123456""; 上面是base64编码的字符串“ window.location.href =” tel:123456“”; I encoded it to be able to use < and > inside the href . 我对它进行了编码,以便能够在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. 最简单的方法是让您仅使用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. 就功能而言(单击后使其自动拨打您的电话号码),请尝试putvande的建议。

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? 也许有Google号码或其他有效的方法? Not sure what automated phone services are out there, but they surely would have some way of tracking the forwards. 不知道那里有什么自动电话服务,但是他们肯定会有某种方式来跟踪前进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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