细看Piwik:一种Google Analytics(分析)替代品,其中之一是Piwik


A recent SitePoint article by Jacco Blankenspoor introduced a number of alternatives to the ubiquitous Google Analytics. Among them was Piwik — a self-hosted, open-source package that Jacco described as a “serious contender”. In this article, I’m going to look at Piwik in more detail, to assess that claim.

Jacco Blankenspoor最近在SitePoint上发表的文章介绍了无处不在的Google Analytics(分析)的许多替代方法 。 其中之一是Piwik,这是一个自托管的开源软件包,Jacco将其描述为“严重的竞争者”。 在本文中,我将更详细地研究Piwik,以评估该主张。

为什么要使用Piwik? (Why use Piwik?)

It’s probably worth starting out by comparing Piwik to the undisputed market-leader, Google Analytics.

比较Piwik与无可争议的市场领导者Google Analytics(分析)可能是值得的。

Google has been the source of a number of privacy concerns recently, leading to a source of discomfort as to what they do with your data. With Piwik, there are no such concerns, as the data is owned by you. You can also be assured that the data won’t be shared with third-parties, particularly advertisers, unless you choose to do so.

谷歌一直是源数量 的 隐私 担忧 最近 ,导致不适的来源,他们与您的数据做什么。 使用Piwik,无需担心,因为数据归您所有。 您还可以确保不会与第三方(尤其是广告客户)共享数据,除非您选择这样做。

Piwik is extremely customisable; the dashboard — Piwik’s default view — is made up of a number of “widgets”, which can be swapped in or out, or rearranged to your preference.

Piwik是非常可定制的。 仪表板(Piwik的默认视图)由许多“小部件”组成,可以将其交换进出,也可以根据自己的喜好进行重新排列。

You can modify Piwik’s appearance as much as you wish — from uploading a logo to brand it, to tweaking the colour scheme — right through to building your own theme from scratch.

您可以根据需要任意修改Piwik的外观-从上传徽标到商标,到调整配色方案-一直到从头开始构建自己的主题。

Because Piwik is self-hosted, you can also specify the domain it sits on.

由于Piwik是自托管的,因此您还可以指定其所在的域。

Piwik has most of the features you’d expect from this kind of service including real-time analytics, visitor maps, goals, campaign tracking, referrer information, and a JavaScript tracking API.

Piwik具有您期望从此类服务获得的大多数功能,包括实时分析,访问者地图,目标,广告系列跟踪,引荐来源信息和JavaScript跟踪API。

For those of you in the European Union, another key advantage is that it conforms to the controversial EU Cookie Law, so if GA is the only reason you’re currently displaying a cookie notice, switching to Piwik means you probably won’t have to (disclaimer: this is an extremely grey area, so you should probably do the necessary research and consult a lawyer locally).

对于您所在的欧盟国家来说,另一个主要优势是它符合有争议的《欧盟Cookie法》 ,因此,如果GA是您当前显示Cookie通知的唯一原因,那么改用Piwik意味着您可能不必(免责声明:这是一个非常灰色的区域,因此您可能应该进行必要的研究并在当地咨询律师)。

Piwik is extensible; there’s even a Marketplace dedicated to third-party plugins (accessible from the settings page), or you could write your own. And because it’s open-source, you could even modify the core.

Piwik是可扩展的。 甚至还有一个专门用于第三方插件的市场(可从“设置”页面访问),或者您可以编写自己的。 并且由于它是开源的 ,因此您甚至可以修改核心。

安装 (Installation)

Piwik is a hosted web application, so you’ll need to upload it to a server somewhere. It doesn’t matter where you put it, though it might make sense to put it on a subdomain, e.g. analytics.example.com.

Piwik是托管的Web应用程序,因此您需要将其上传到某处的服务器。 放置在什么位置都没有关系,尽管将其放置在子域(例如analytics.example.com上可能很有意义。

Download Piwik and upload it to your server. Alternatively, use the command line:

下载Piwik并将其上传到您的服务器。 或者,使用命令行:

wget http://builds.piwik.org/latest.zip
unzip latest.zip
cp -R piwik /var/www/analytics.example.com

A number of directories need to be writeable by the web server:

Web服务器需要可写许多目录:

/tmp
/tmp/assets/
/tmp/cache/
/tmp/logs/
/tmp/tcpdf/
/tmp/templates_c/

Next, you’ll need to create a MySQL database for it. The database user used by Piwik needs permissions to read, write, and modify the schema.

接下来,您需要为其创建一个MySQL数据库。 Piwik使用的数据库用户需要读取,写入和修改模式的权限。

Once your virtual host is set up, navigate to it in your browser to begin the setup wizard.

设置虚拟主机后,请在浏览器中导航至该主机,以开始设置向导。

The wizard will first list the dependencies and check whether they’re all met. It’ll ask you for the database connection details, and then ask you to create a “super user” account. Next, it’ll ask you to add your first website. At this point you’ll need to give the site a name, provide its URL, specify the city (for calculating the time zone) and whether it’s an e-commerce site. You can add more websites later.

该向导将首先列出依赖性,并检查它们是否都满足。 它将要求您提供数据库连接详细信息,然后要求您创建一个“超级用户”帐户。 接下来,它将要求您添加第一个网站。 此时,您需要给该站点起一个名字,提供其URL,指定城市(用于计算时区),以及它是否是一个电子商务站点。 您可以稍后添加更多网站。

Next, it will generate and display the JavaScript tracking code for you; if you’re using a plugin you may not need this as-is, but otherwise you can simply paste it into your website’s page templates. Once you’ve finished the installation, it’ll ask you to sign-in with the super-user account you just created.

接下来,它将为您生成并显示JavaScript跟踪代码; 如果您使用的是插件,则可能不需要原样,否则,您只需将其粘贴到网站的页面模板中即可。 完成安装后,它将要求您使用刚刚创建的超级用户帐户登录。

Next up, we’ll start looking at some of the functional areas of Piwik.

接下来,我们将开始研究Piwik的一些功能领域。

目标 (Goals)

Goals are used to measure the effectiveness of a website with respect to business objectives. Some examples of goals you might track from your visitors:

目标用于衡量网站在业务目标方面的有效性。 您可以从访问者中跟踪目标的一些示例:

  • Registering on the site

    在网站上注册
  • Making a purchase

    进行购买
  • Subscribing to a newsletter

    订阅新闻通讯
  • Making an inquiry using the contact form

    使用联系表进行查询
  • Downloading a brochure or other document

    下载小册子或其他文件

To add a goal, go to “Goals” then choose “Add a new goal”. Start by giving the goal a name, for example “Downloaded brochure”. Next, you can set the goal to be triggered based on the user visiting a page, downloading a file, or clicking a link. It’s common to trigger goals when people land on confirmation pages, for example alongside the thank-you message that appears when you’ve completed a contact form.

要添加目标,请转到“目标”,然后选择“添加新目标”。 首先给目标命名,例如“下载的手册”。 接下来,您可以根据用户访问页面,下载文件或单击链接来设置要触发的目标。 人们进入确认页面时通常会触发目标,例如,在您完成联系表时会出现“谢谢”消息。

Next, decide whether this is a “one-time” goal, or whether it makes sense for the goal to be triggered multiple times. This really depends on your business objectives and the goal itself; subscribing to a newsletter is probably a one-time goal, whereas making a purchase would be multiple.

接下来,确定这是一个“一次性”目标,还是多次触发该目标是否有意义。 这实际上取决于您的业务目标和目标本身。 订阅时事通讯可能是一次性目标,而进行购买则可能是多次。

Consider using expressions instead of exact URLs; otherwise it may match http://example.com/newsletter/thanks but not https://example.com/newsletter/thanks or http://www.example.com/newsletter/thanks (notice the “https” and “www”). Whereas, (.*)/newsletter/thanks would match them all.

考虑使用表达式而不是确切的URL; 否则,它可能与http://example.com/newsletter/thanks匹配,但与https://example.com/newsletter/thankshttp://www.example.com/newsletter/thanks不匹配(请注意,“ https”和“万维网”)。 而(.*)/newsletter/thanks将使它们全部匹配。

You may wish to add the Goals widget to the dashboard. Browse to the dashboard, click the “Widgets & Dashboard” button, hover over “Goals” then click “Goals Overview”. The widget should appear on your dashboard, and you can now drag it to your preferred position on the page.

您可能希望将“目标”小部件添加到仪表板。 浏览到仪表板,单击“小部件和仪表板”按钮,将鼠标悬停在“目标”上,然后单击“目标概述”。 该小部件应该出现在您的仪表板上,现在您可以将其拖动到页面上的首选位置。

跟踪活动 (Tracking Campaigns)

A vital part of any marketing campaign is measuring its effectiveness. When your campaign is designed to direct people to your site, you can use a tracking code to record it.

任何营销活动的重要组成部分都是衡量其有效性。 当您的广告系列旨在将人们定向到您的网站时,您可以使用跟踪代码进行记录。

To do this with Piwik, first incorporate a parameter into the URL to the site in question, for example when linking to the site in your promotional emails or a in a Tweet. You can call the parameter whatever you want, and there’s no set format for the value — as long as it will make sense to you later. Here are a few examples:

要使用Piwik做到这一点,首先要在相关网站的网址中加入参数,例如,在促销电子邮件或推文中链接至该网站时。 您可以随心所欲地调用参数,并且该值没有设置格式,只要以后对您有意义即可。 这里有一些例子:

http://www.example.com?campaign=email_march_2014http://www.example.com?source=twitterhttp://www.example.com?fb_post_id=123456789

http://www.example.com?campaign=email_march_2014 http://www.example.com?source=twitter http://www.example.com?fb_post_id=123456789

You can also use hashtags for your tracking codes, e.g.

您也可以将标签用于跟踪代码,例如

http://www.example.com#campaign=email_march_2014

http://www.example.com#campaign=email_march_2014

The advantage of this approach is that you won’t be penalised by search engines for having duplicate URLs.

这种方法的优势在于,搜索引擎不会因URL重复而受到惩罚。

To view your campaign stats, in Piwik, click Referrers in the main navigation, then Campaigns. You can also add a widget to your dashboard: Widgets & Dashboard -> Referrers -> Campaigns.

要查看您的广告系列统计信息,请在Piwik中,点击主导航栏中的Referrers,然后点击Campaigns。 您还可以将小部件添加到仪表板:小部件和仪表板->引荐来源网址->广告系列。

地理位置 (Geolocation)

By default, Piwik tries to guess where visitors are based on their language settings. This is a flawed approach, however, that’s pretty likely to distort your geo-based analytics data.

默认情况下,Piwik会根据他们的语言设置尝试猜测访客的位置。 这是一种有缺陷的方法,但是很可能会扭曲基于地理的分析数据。

To improve the quality of this information, download the Geolite City file from Maxmind, then copy it to Piwik’s misc directory.

为了提高此信息的质量,请从Maxmind下载Geolite City文件,然后将其复制到Piwik的misc目录。

To do that on the command line:

要在命令行上执行此操作:

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
cp GeoLiteCity.dat /var/www/analytics.example.com/misc/

Then, go to Settings -> Geolocation and select “GeoIP (Php)”. On that page you can also see that approach’s conclusions about where you are, compared to the default method based on your language settings. Although not fool-proof, you’ll probably find that the GeoIP approach is considerably more accurate.

然后,转到设置->地理位置,然后选择“ GeoIP(Php)”。 与基于您的语言设置的默认方法相比,在该页面上您还可以看到该方法有关您所在位置的结论。 尽管不是万无一失,但您可能会发现GeoIP方法更加准确。

For even better geolocation, you can purchase premium geo databases, and you can even set up Piwik to update the database automatically.

为了获得更好的地理位置,您可以购买高级地理数据库,甚至可以将Piwik设置为自动更新数据库。

网站和高级网站设置 (Websites and Advanced Website Settings)

If you select Settings (top-right) then Websites (on the left hand side, under “Manage”), you’ll get a list of the websites you’ve configured, and you can add more from there.

如果选择“设置”(右上),然后选择“网站”(在左侧的“管理”下),则将获得已配置网站的列表,您可以从中添加更多内容。

If you click Edit next to a website, you also get access to some additional settings, several of which are also available as global settings. Here are a few of them.

如果单击网站旁边的“编辑”,则还可以访问其他一些设置,其中一些也可以用作全局设置。 这里有几个。

排除的IP (Excluded IPs)

You can exclude certain IP addresses from being tracked. This is useful when you or another analytics user — for example, your client — have a static IP address or range, and you wish to exclude their visits from reports.

您可以排除某些IP地址,使其不受跟踪。 当您或其他分析用户(例如您的客户端)具有静态IP地址或范围,并且希望从报告中排除他们的访问时,此功能将非常有用。

排除参数 (Excluded Parameters)

Some URL parameters, such as session IDs, are irrelevant to tracking. Many, such as phpsessid and sessionid, are stripped out automatically, but if the system that powers a particular site uses something else, you can set that here.

某些URL参数(例如会话ID)与跟踪无关。 许多内容(例如phpsessidsessionid )会自动删除,但是如果为特定站点提供支持的系统使用其他功能,则可以在此处进行设置。

You can also track searches on the site itself. Simply specify the search parameter (e.g. q, query or search) and Piwik will pick it up. (To find out what parameter your site uses, either inspect the URL after a search, or check the name attribute of the search box.)

您也可以在网站本身上跟踪搜索。 只需指定搜索参数(例如qquerysearch ),Piwik就会选择它。 (要了解您的网站使用了什么参数,请在搜索后检查URL,或在搜索框中选择name属性。)

用户数 (Users)

You can add as many user accounts as you wish, and control their access to websites on an individual basis. Go to Settings -> Users to add a new user, edit existing users, or manage their permissions.

您可以根据需要添加任意数量的用户帐户,并分别控制他们对网站的访问。 转到设置->用户以添加新用户,编辑现有用户或管理其权限。

Note: in case you’re wondering, the token_auth field is used for API calls.

注意:如果您想知道,token_auth字段用于API调用。

JavaScript应用 (JavaScript Applications)

If your application uses Ajax page transitions, or if you’re using a front-end framework such as Angular JS, Ember, or Backbone, you’ll probably need the JavaScript API. As well as being able to log page views programmatically, you can also pass custom variables.

如果您的应用程序使用Ajax页面转换,或者使用的是诸如Angular JS,Ember或Backbone之类的前端框架,则可能需要JavaScript API 。 除了能够以编程方式记录页面浏览量之外,您还可以传递自定义变量 。

For example, to track a page view on a JavaScript event:

例如,要跟踪JavaScript事件的页面浏览量:

<a href="About" onclick="javascript:_paq.push(['trackPageView', 'About']);">About</a>

Or using jQuery:

或使用jQuery:

$('nav a').click(function(){
  _paq.push(['trackPageView', $(this).data('title')]);
});

To pass a custom variable:

传递自定义变量:

_paq.push(['setCustomVariable','1','VisitorType','Member']);

You can also use JavaScript to track a goal:

您还可以使用JavaScript跟踪目标:

_paq.push(['trackGoal', 1]);

You can also track a goal along with a specific revenue. For example, on an order confirmation page you might do this, injecting the relevant information into the page using PHP:

您还可以跟踪目标以及特定收入。 例如,您可以在订单确认页面上执行此操作,使用PHP将相关信息注入页面:

_paq.push(['trackGoal', 1, <?php echo $order->getTotal(); ?>]);

For analytics.js users, there’s a fork which supports Piwik on Github.

对于analytics.js用户, Github上有一个支持Piwik的fork。

整合方式 (Integrations)

There are a number of available integrations for Piwik, for example Drupal, WordPress, Magento, Silex, Laravel, as well as client and tracking API’s for PHP.

Piwik有许多可用的集成 ,例如Drupal , WordPress , Magento , Silex , Laravel ,以及用于PHP的客户端和跟踪 API。

移动 (Mobile)

Piwik offers mobile apps for iPhone and Android.

Piwik提供适用于iPhone和Android的移动应用程序。

更多信息 (Further Information)

There are a number of videos talking you through several aspects of Piwik on Youtube.

在YouTube上有许多视频介绍Piwik的各个方面。

Piwik的缺点 (Disadvantages of Piwik)

Being self-hosted introduces its own disadvantages. It takes time and effort and technical knowledge to set up Piwik. It uses server resources, and it’s up to you to manage any downtime.

自我托管会带来自身的弊端。 设置Piwik需要时间,精力和技术知识。 它使用服务器资源,由您来管理任何停机时间。

Inevitably there’s also a learning curve, so switching clients over could cause some friction. Of course, there’s nothing to stop you running it alongside your current solution while you or your users familiarize themselves with it.

不可避免地还会有一个学习曲线,因此切换客户可能会引起一些摩擦。 当然,当您或您的用户熟悉它时,没有什么可以阻止它与当前解决方案一起运行。

摘要 (Summary)

Google Analytics has some serious competition from Piwik, the self-hosted web analytics solution. For me, the benefits of having control over my or my clients’ own data — coupled with some very real concerns about Google’s privacy policies — far outweigh the drawbacks of self-hosting.

Google Analytics(分析)与自托管的网络分析解决方案Piwik有着激烈的竞争。 对我来说,控制我或我的客户自己的数据的好处,再加上对Google隐私政策的一些非常现实的担忧,远远超过了自我托管的弊端。

However, this is a very subjective reason, so I’ll leave you to decide for yourself. But I’d love to hear what you think in the comments.

但是,这是一个非常主观的原因,所以我让您自己决定。 但我很想听听您在评论中的想法。

翻译自: https://www.sitepoint.com/closer-look-piwik-google-analytics-alternative/

相关内容