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