[英]Mobile tracking google analytics and google tag manager
I want to track how many user click the call button on the website in mobile view. 我想跟踪多少用户在移动视图中单击网站上的呼叫按钮。 The concern is that call button is placed on two pages having same code. 令人关注的是,呼叫按钮位于具有相同代码的两个页面上。
I have place the below code to track the activity.but since the same code is placed on two different page. 我放置了以下代码来跟踪活动。但是由于同一代码位于两个不同的页面上。 I am not able figure how many user click from which page. 我无法确定有多少用户从哪个页面单击。 Page url is static it doesn't change.So we are using event tracking the differentiate. 页面网址是静态的,不会改变。因此,我们使用事件跟踪来区分。 I have attached screenshot of the GTM & Web pagecode. 我已附上GTM和Web页面代码的屏幕截图。 The line highlighted in grey in image is were the phone no. 图片中以灰色突出显示的线是电话号码。 & class code ( i could not share the mobile no. & class due to security). &类别代码(出于安全原因,我无法共享手机号码&类别)。 Also i have highlighted the only class that differ in code ( " pane-bean-additional-resources-about-trume" & pane-bean-safety-and-dosing-banner") 我也强调了唯一在代码上有所不同的类(“ pane-bean-additional-resources-about-trume”和“ pane-bean-safety-and-dosing-banner”)
jQuery(".bw-mobile .ga-dosipage").click(function() {
try {
dataLayer.push({
'event': 'lear-more',
'category': 'Call',
'action': 'Click',
'label': 'Page - abc'});
} catch (err) {}
});
Can any body assist me with change in code at GTM level. 任何机构都可以协助我更改GTM级别的代码。
Thanks in advance. 提前致谢。
If that css class is the differentiating factor you can use some JavaScript to check which version you are on. 如果该CSS类是差异化因素,则可以使用一些JavaScript来检查您所使用的版本。 The code could look like this: 代码看起来像这样:
function getPageVersion(){
var page = document.querySelectorAll(".pane-bean-safety-and-dosing-banner");
if(page.length>=1){
return "Page Version A";
}else{
return "Page Version B";
}
}
This will return "Page Version A" if it can find that css Class on the page and return "Page Version B" if it can't. 如果可以在页面上找到css类,则将返回“页面版本A”,如果找不到,则将返回“页面版本B”。 This way you can change: 这样您可以更改:
'label': 'Page - abc'
to: 至:
'label': getPageVersion()
If you want a pure GTM solution just put the code I put above in a Custom JavaScript Variable
(don't forget to remove the function name). 如果您想要一个纯GTM解决方案,只需将我上面输入的代码放在“ Custom JavaScript Variable
(请不要忘记删除函数名)。 You can then use {{NAME OF THE GTM JS VAR}}
in the Event Label
part of the Analytics Tag
and set the Trigger
to Click
, any click
, enabled on the page the button is on, and filter to Click Class contains
whatever your button class is. 然后,您可以在Analytics Tag
的“ Event Label
部分中使用{{NAME OF THE GTM JS VAR}}
of the {{NAME OF THE GTM JS VAR}}
,并将“ Trigger
设置为Click
, any click
,在按钮所在页面上启用的any click
,以及Filter Click Class contains
您的任何内容的Click Class contains
按钮类是。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.