【发布时间】:2017-09-01 06:26:19
【问题描述】:
我有一个脚本,人们点击“给我们打电话”,然后出现号码并发送 GA 事件。
是否可以将该号码链接到 tel:-link,以便您可以在手机上拨打该号码?
我尝试插入一个 ID,但在手机上无法点击该号码。
感谢您的任何回答, 戴夫
这是脚本:
function ipTrackButton(){
if(window.jQuery){
var $ = jQuery;
var phonenumber = '+31 (0)20 - 679 62 22',
holder = $('#text-5 > .textwidget'),
newHTML = 'T: <span id="ipCallButton">Bel ons | Call us</span><br>E: <a href="mailto:info@pvhadvocaten.nl">info@pvhadvocaten.nl</a>',
body = $('body');
//Inject styles
var style = '#ipCallButton { background-color:#eaeaea;padding:5px 8px;cursor:pointer;text-decoration:underline; } #ipCallButton.ipClicked { text-decoration:none;cursor:default; } ';
body.append('<style>'+style+'</style>');
//Set new content
holder.html(newHTML);
//Set event
body.on('click', '#ipCallButton:not(.ipClicked)', function(){
var _this = $(this);
_this.html(phonenumber);
_this.addClass('ipClicked');
//Send event
ga('send', 'event', 'Contact', 'Click', 'Telefoonnummer');
});
}
else {
setTimeout(ipTrackButton, 50);
}
}
ipTrackButton();
【问题讨论】:
标签: javascript jquery events hyperlink