Website Statistics-piwik

Source: Internet
Author: User
Tags time zones php and mysql piwik

Help do a lot of web site statistics, such as Google Analytics, Baidu Statistics, Mixpanel, and so on, but these can not be deployed on their own server statistical services. Piwik is a PHP and MySQL implementation of open-source web statistics software, can generate a lot of useful web site statistics reports, but also through the plug-in to expand functionality.

Piwik Introduction of Piwik Features
    1. Open source projects;
    2. No data storage limits;
    3. Community support;
    4. View data wherever you are;
    5. Support for 53 languages and all time zones;
    6. 5 minutes to complete the installation, 1 keys to update.
What Piwik can use to do
    1. Web Analytics;
    2. e-commerce analysis;
    3. Service-side log analysis;
    4. Intranet analysis.
View information about a user on the site
    1. Customizable Thunderbolt dial;
    2. Real-time data;
    3. View calendar hoot data, compare multiple aspects at a time;
    4. Geolocation analysis.
Piwik installation scripts and steps on Amazon Linux install the necessary software through Yum
sudo yum update -ysudo yum groupinstall -y "Development Tools"sudo yum install -y nginx mysql-server php56-fpm php56-mysqlnd php56-gd php56-mbstring# 查找php5相关可安装包# sudo yum search php5
Start MySQL
sudo service mysqld start# 添加开机启动sudo chkconfig mysqld on
Configure and start PHP
sudo vi /etc/php-fpm.d/www.conf# 将user和group从apache改为nginx----------------------user = nginxgroup = nginx----------------------sudo /etc/init.d/php-fpm start# 添加开机启动sudo chkconfig php-fpm on# PHP其他命令记录# sudo /etc/init.d/php-fpm stop# sudo /etc/init.d/php-fpm restart
Configure and start Nginx
sudo vi /etc/nginx/nginx.conf----------------------# 放开 php 的注释并稍做调整location ~ \.php$ {    root html;    fastcgi_pass 127.0.0.1:9000;    fastcgi_index index.php;    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;    include fastcgi_params;}----------------------sudo nginx# 添加开机启动sudo chkconfig nginx on
Download Piwik
cd /usr/share/nginx/htmlsudo wget http://builds.piwik.org/piwik.zipsudo unzip piwik.zipsudo chown -R nginx:nginx piwik
Go to Installation page
http://54.223.189.12/piwik/index.phpWelcome! 点 Next。System Check 会检查系统是否满足安装Piwik的条件,安装了上述内容就可以。点 Next。Database Setup 设定 login = root,Database Name = piwik,其余都默认。点 Next。Creating the Tables 点 Next。Super User 设定 Piwik 的超级管理员,根据需要设定完。点 Next。(u3d / [email protected])Setup a Website 设定使用 Piwik 的网站。根据提示设定。点 Next。JavaScript Tracking Code 复制页面提供的 JavaScript 跟踪代码到网站页面内,这部可以以后再做。点 Next。Congratulations 根据需要调整 Piwik 的配置,完成后点 Continue to Piwik。

After the installation is complete, log in with the Piwik Super admin you just set up. After logging in, because there is no data, it prompts you to add JavaScript tracking code.

Piwik API Demo The simplest page to access demo

Add code similar to the following in the page:

<!-- Piwik --><script type="text/javascript">    var _paq = _paq || [];    _paq.push([‘trackPageView‘]);    _paq.push([‘enableLinkTracking‘]);    (function() {        var u="//54.223.224.220/piwik/";        _paq.push([‘setTrackerUrl‘, u+‘piwik.php‘]);        _paq.push([‘setSiteId‘, 1]);        var d=document, g=d.createElement(‘script‘), s=d.getElementsByTagName(‘script‘)[0];        g.type=‘text/javascript‘; g.async=true; g.defer=true; g.src=u+‘piwik.js‘; s.parentNode.insertBefore(g,s);    })();</script><!-- End Piwik Code -->

Visit a page with the above code, you can see the logged access statistics in the Piwik console:

Page with guest Information Access demo

Add code similar to the following in the page:

<!-- Piwik --><script type="text/javascript">    var _paq = _paq || [];    _paq.push([‘trackPageView‘]);    _paq.push([‘enableLinkTracking‘]);    (function() {        var u="//54.223.224.220/piwik/";        _paq.push([‘setTrackerUrl‘, u+‘piwik.php‘]);        _paq.push([‘setSiteId‘, 1]);        var d=document, g=d.createElement(‘script‘), s=d.getElementsByTagName(‘script‘)[0];        g.type=‘text/javascript‘; g.async=true; g.defer=true; g.src=u+‘piwik.js‘; s.parentNode.insertBefore(g,s);    })();    _paq.push([‘setUserId‘, ‘1234567890‘]);    _paq.push([‘setCustomVariable‘, 1, ‘Name‘, ‘Tom‘, ‘visit‘]);    _paq.push([‘setCustomVariable‘, 2, ‘Email‘, ‘[email protected]‘, ‘visit‘]);</script>

Visit a page with the above code to see the visitor information in the Visitors-visitor Log of the Piwik console:

Event Log Demo

Add code similar to the following in the page:

<!--Piwik--><script type= "Text/javascript" > var _paq = _paq | |    [];    _paq.push ([' Trackpageview ']);    _paq.push ([' enablelinktracking ']);        (function () {var u= "//54.223.224.220/piwik/";        _paq.push ([' Settrackerurl ', u+ ' piwik.php ']);        _paq.push ([' Setsiteid ', 1]);        var d=document, g=d.createelement (' script '), S=d.getelementsbytagname (' script ') [0]; G.type= ' Text/javascript '; G.async=true; G.defer=true; g.src=u+ ' Piwik.js ';    S.parentnode.insertbefore (g,s);    })();    _paq.push ([' Setuserid ', ' 1234567890 ']);    _paq.push ([' setcustomvariable ', 1, ' Name ', ' Tom ', ' visit ']); _paq.push ([' setcustomvariable ', 2, ' Email ', ' [email protected] ', ' visit ']);</script><!--End Piwik Code --><a href= "#" onclick= "Javascript:_paq.push ([' trackEvent ', ' work ', ' Login ']);" >login</a><a href= "#" onclick= "Javascript:_paq.push ([' trackEvent ', ' work ', ' Open ', ' 123456789098774 ']);" >open work</a><a href= "#" onclick= "javascript:_paq.push ([' trackEvent ', ' work ', ' Close ', ' 123456789098774 ']); >close work</a><a href= "#" onclick= "Javascript:_paq.push ([' Trackgoal ', 1, 10]);" >track goal</a><a href= "#" onclick= "Javascript:_paq.push ([' Tracksitesearch ', ' Keyword-Taipei ', ' Category1 ', 10]); " >track sitesearch</a><a href= "#" onclick= "Javascript:_paq.push ([' Tracklink ', ' http://www.baidu.com ', ' Link ']); " >track link</a>

Visit the page and click all the buttons once, or go to Piwik's Visitor Log to see the following information:

Website Statistics-piwik

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.