www.it-ebooks.info Piwik Web Analytics Essentials A complete guide to tracking visitors on your websites, e-commerce shopping carts, and apps using Piwik Web Analytics Stephan A. Miller BIRMINGHAM - MUMBAI www.it-ebooks.info Piwik Web Analytics Essentials Copyright © 2012 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: October 2012 Production Reference: 1270912 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84951-848-2 www.packtpub.com Cover Image by Avishek Roy (roy007avishek88@gmail.com) www.it-ebooks.info Credits Author Stephan A. Miller Reviewers Amir Shaked Adrian Speyer Deepak Vohra Acquisition Editor Usha Iyer Lead Technical Editor Kedar Bhat Technical Editors Farhaan Shaikh Jalasha D'costa Veronica Fernandes Copy Editors Aditya Nair Alda Paiva Project Coordinator Yashodhan Dere Proofreader Maria Gould Indexer Hemangini Bari Production Coordinators Nilesh R. Mohite Manu Joseph Cover Work Nilesh R. Mohite www.it-ebooks.info About the Author Stephan A. Miller is a web and app developer, SEO expert, and blogger who lives in Kansas City, Missouri. He was head developer at All About Doors and Windows in Kansas City for six years and was a freelance developer and SEO expert for eight years. In his career, he has worked with Wordpress, Drupal, Magento, osCommerce, ZenCart, and many other online applications, as well as developing sites from scratch in PHP and MySQL or using the Lithium PHP framework. But this is not all. Because his business was at times a one man show, he knows Linux, Apache, and Nginx well and has developed desktop applications in Python where PHP just won't work. He also knows search engine optimization techniques, web analytics software, and search engine marketing which he uses to promote his own handful of sites. He blogs semi-regularly at http://www.stephanmiller.com about his work. I would like to thank Usha Iyer for contacting me with the idea for this book; Matthieu Aubry, the Project Leader at Piwik.org, for providing input on the book and the necessary screenshots I was missing and helping me with the Piwik Zen Cart plugin; Maarten Vonz for contributing and working with me on the open source project for the Piwik Zen Cart plugin; and Ruud Hein of Search Engine People, who published a post on Piwik for me. I would also like to thank all of my technical reviewers for making sure the book turned out as well as it did. www.it-ebooks.info About the Reviewers Amir Shaked is an R&D manager by day and software developer by night. He is procient in several technologies, such as C#, WPF, PHP, Python, Java Script, Data Systems, Networks, and more. In recent years, he has been working on several open source projects for Windows (including eLibrary: openelibrary.org), Android, and web applications. Through his work on open source and websites he discovered Piwik, and has since used, tweaked, and customized it for several projects. He blogs on his website amirshk.com on various technical issues. Deepak Vohra is a consultant and a principal member of the NuBean.com software company. He is a Sun Certied Java Programmer and Web Component Developer, and has worked in the elds of XML and Java programming and J2EE for over ve years. He is the co-author of Pro XML Development with Java Technology, Apress and was the technical reviewer for WebLogic: The Denitive Guide, O'Reilly. He was also the technical reviewer for Ruby Programming for the Absolute Beginner, Thomson Course Technology PTR, and the technical editor for Prototype and Scriptaculous in Action, Manning Publications. He is also the author of JDBC 4.0 and Oracle JDeveloper for J2EE Development, Packt Publishing, Processing XML documents with Oracle JDeveloper 11g, Packt Publishing, and EJB 3.0 Database Persistence with Oracle Fusion Middleware 11g, Packt Publishing. www.it-ebooks.info www.PacktPub.com Support les, eBooks, discount offers and more You might want to visit www.PacktPub.com for support les and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub les available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? • Fully searchable across every book published by Packt • Copy and paste, print and bookmark content • On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. www.it-ebooks.info www.it-ebooks.info www.it-ebooks.info I dedicate this book to my best friend Erin, who convinced me that I should write this book and for putting up with me while I did, and to my kids—Jared and Maddie—who I hope nd even bigger dreams come true for them in their lives www.it-ebooks.info [...]... folder: mv piwik NEW_FOLDER °° Move it to the document root: mv -r /piwik/ * / Uploading to a web hosting account If you have put Piwik on a local web server or used wget to download Piwik to your Linux web host, you can skip this section For those of you who still need to get Piwik to its home on a web server, it's time to decide how you are going to do that If your web hosting company is running a web- based... Chapter 10, Piwik Integration, explains how to integrate Piwik into various CMS and CRM platforms, how to access Piwik when mobile, and the basics of using the Piwik Analytics API to create custom tracking applications You will also learn how to embed Piwik widgets on other websites and how Piwik can be embedded in your own projects Appendix A, Tracking API Reference, is a minimal glossary of the Piwik Tracking... Downloading Piwik Downloading Piwik with SSH Uploading to a web hosting account Uploading using cPanel or other file managers Uploading using FTP Creating a database for your installation Creating a user and database for Piwik in cPanel Creating a user and database for Piwik with phpMyAdmin Creating a user and database for Piwik with SSH Using the Piwik installation wizard Securing Piwik Backing up Piwik. .. JavaScript Reading and using Piwik' s e-commerce reports A note about SSL Summary Changing your Super User settings Creating users in Piwik Managing website access Who is a Super User? What are admin permissions? What are view permissions? Managing websites Adding a website Editing or deleting a website Editing the global website settings Tracking multiple domains or subdomains with one website account Setting... with Piwik via code and code will be sprinkled throughout the book Who this book is for This book is for anyone who wants an open source solution for web analytics It is suitable for bloggers, website owners, JavaScript application developers, or analytics professionals It will benefit those new to web analytics as well as experienced users and developers And it will take you from installing Piwik. .. through the setup and installation of Piwik Open Source Web Analytics on a web server or on your local computer in a test server environment This is not a complicated procedure, but there are a few ways to set up your Piwik installation, and a couple of choices you will have to make during the installation procedure Piwik can be downloaded easily from its website at http:/ /piwik. org/ It is a free and open... of Piwik are not very hard to meet Most hosting companies' standard PHP and MySQL packages will meet these requirements • First, you need a web server The most common, Apache, is the standard for most Piwik installations Piwik also runs well on light web servers like Nginx or lighttpd In fact, for high traffic websites, a light web server is the recommended option But if you are a beginner with Piwik. .. www.it-ebooks.info Chapter 1 Downloading Piwik Once you have the environment for Piwik ready and you are waiting for a brand new Piwik installation, it is time to go to the Piwik website http:/ /piwik. org and download the Piwik archive file Just like the screenshot below, you should be able to see a big orange button containing the download link to the current version of Piwik The current version, during the... Dashboard widget The All Websites widget Choose your own widget 248 249 250 Accessing Piwik' s data How to call the analytics API 252 252 Including graphs Using the Live! API Segmentation Creating a change log for your website with analytics feedback Summary 260 262 264 266 273 Calling the analytics API using REST Calling the analytics API locally Appendix A: Tracking API Reference The Piwik tracking API... tracker Tracking visitors with other programming languages Java Python Silverlight Flash Using Piwik' s tracking API directly Debugging your tracking code Piwik plugins How Piwik works The anatomy of a plugin Writing a simple Piwik plugin Summary Chapter 10: Piwik Integration CMS plugins Piwik Mobile Embedding Piwik widgets Give your anonymous user rights Choosing your widget 214 215 217 219 221 225 226 . www.it-ebooks.info Piwik Web Analytics Essentials A complete guide to tracking visitors on your websites, e-commerce shopping carts, and apps using Piwik Web Analytics Stephan A. Miller . any type of website needs web analytics software such as Piwik to help them hear what their visitors are saying. Web analytics began as simple log parsing to determine how many hits a website would. deleting a website 194 Editing the global website settings 195 Tracking multiple domains or subdomains with one website account 196 Setting up an intranet as a website in Piwik 197 Turning Piwik into