0
我有一个脚本,用户点击“给我们打电话”,出现号码并发送GA事件。在点击事件中插入链接
是否有可能将号码链接到电话号码 - 链接,以便您可以拨打移动电话号码?
我试着插入一个ID,但是这个号码不能在手机上点击。
感谢您的任何答案, DAV
这是脚本:
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:[email protected]">[email protected]</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();
谢谢您的回答!不过,您的解决方案会在我的桌面版Chrome中同时显示文字和数字;该数字是可点击的。在我的iPhone上只显示数字,但仍然不可点击。您的其他解决方案看起来很有希望,但我希望修复当前的脚本。 –
@davisra刚试过在Chrome浏览器中剪下来,它适用于我。看起来您需要更好地了解为什么会发生这种情况,然后再尝试整合我的解决方案。 – amphetamachine