Wordpress和谷歌分析事件 [英] Wordpress and Google Analytics Events

查看:146
本文介绍了Wordpress和谷歌分析事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想跟踪Google Analytics中的某些操作,但无法正常工作。

I want to track some actions in Google Analytics but I can't get it working.

我试用了联系表单(Wordpress)。在附加设置中,我只写了:

I tried it with Contact Forms (Wordpress). At the additional settings I just wrote:

on_sent_ok: "ga('send', 'event', 'Formular-Beratung', 'sent');"

但它不起作用。我安装了Google标签助理,但我无法看到任何事件(即使在Google Analytics的实时视图中也没有)。

but it does not work. I installed the Google tag assistant, but I cant see any event (not even in the live view at Google Analytics).

下一个:

是一个实时聊天(snapengage)。在这里您还可以跟踪事件。为此,我实现了代码

Next:
There is a live chat (snapengage). Here you can also track events. For this I implemented the code

var seAgent;
SnapABug.setCallback('StartChat', function (email, msg, type) {
    seAgent = agent;
    ga('send','event','SnapEngage', 'hasChatted', email);
});

我从官方网站获得了这个信息:请参阅此处

I got this from there official site: see here

此代码应向Google发送事件,在聊天中发送消息),但没有任何反应。

This code should send an event to Google, when someone is sending a message in the chat), but nothing happens.

好像整个网站不会向Google发送任何活动。

It seems like the whole site does not send ANY events to Google.

这是我正在谈论的网站。请问有人可以看看这个吗?

This is the site I am talking about. Please could anybody have a look at this?

推荐答案

您需要确保初始化跟踪器对象,然后再调用 ga()方法。您可以通过将此代码放置在页面源代码的顶部(位于< body> 元素之后:

You need to make sure that you initialize the tracker object before you call the ga() method. You do this by placing this code at the top of the source code of your page (right after the <body> element:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-XXXXXXXX-Y', 'auto');
</script>

确保使用您自己的房产ID替换UA-XXXXXXX-Y。

Make sure to replace the UA-XXXXXXX-Y with your own property ID.

这篇关于Wordpress和谷歌分析事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆