<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>StatStory</title>
	<atom:link href="http://www.statstory.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.statstory.com</link>
	<description>It&#039;s All About Measurement</description>
	<lastBuildDate>Fri, 05 Apr 2013 10:44:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=Updated</generator>
		<item>
		<title>Google Analytics, Custom Variables And Contact Form 7</title>
		<link>http://www.statstory.com/google-analytics-custom-variables-and-contact-form-7/</link>
		<comments>http://www.statstory.com/google-analytics-custom-variables-and-contact-form-7/#comments</comments>
		<pubDate>Thu, 04 Apr 2013 02:19:07 +0000</pubDate>
		<dc:creator>Adrian Speyer</dc:creator>
				<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[contact form 7]]></category>
		<category><![CDATA[Contact7]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.statstory.com/?p=741</guid>
		<description><![CDATA[WordPress Contact Form 7 As we have covered before, Contact Form 7 is a very popular form plugin for WordPress. Over 10 Million people use the plugin, which is an amazing number. Unfortunately, lots of the good info about Contact7 form is hidden, like these special tags you can add to your mail to get [...]<p><a href="http://www.statstory.com/google-analytics-custom-variables-and-contact-form-7/">Google Analytics, Custom Variables And Contact Form 7</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></description>
				<content:encoded><![CDATA[<p><strong>WordPress Contact Form 7</strong><br />
As we have covered <a href="http://www.statstory.com/tracking-contact-form-7-with-piwik-google-analytics/" title="Tracking with Contact 7 Form">before</a>, <a href="http://wordpress.org/extend/plugins/contact-form-7/" title="Contact 7 Form">Contact Form 7</a> is a very popular form plugin for WordPress. Over 10 Million people use the plugin, which is an amazing number. Unfortunately, lots of the good info about Contact7 form is hidden, like these <a href="http://contactform7.com/special-mail-tags/" title="special mail tags">special tags</a> you can add to your mail to get more info about the user who sends you a message. There is also a great plugin to add <a href="http://wordpress.org/extend/plugins/contact-form-7-modules/" title="Hidden Fields">hidden fields</a> in Contact Form 7. Then there is (i my view) the most powerful way you can use Contact Form 7: The Additional Settings Box and the &#8220;on_ok_send&#8221; command. The additional settings box is found at the very bottom of every contact form setting page. With the &#8220;on_ok_send&#8221; command, you can execute any Javascript you want at the time the email is sent. Best of all you can enhance the usefulness of your forms with the power of Google (or Piwik) Analytics. More specifically you can use Events or with Custom Variables, and you get to go to a whole different level of intelligence.</p>
<p><strong>A Note on PII</strong><br />
With email you have to be careful with PII (Personally Identifiable Information) and Google Analytics. When you you use Google, you are not allowed to use personal information in your analytics. For example YOU CANNOT use a Custom Variable, which inserts a perons name or email into Google Analytics and ties to their site behaviour. Google takes this very seriously and you can have you account suspended if you you use information improperly. You can of course use Google Analytics to categorize your users, such as lead types for example &#8211;or consider using <a href="http://piwik.org/" title="Piwik Analytics">Piwik</a>, which as a self hosted solution does not have this issue.</p>
<p><strong>Contact 7 Form setup</strong><br />
Now that we have understood the limits of PII, we can have fun getting data to segment on our form submitters. The first step is to add a new element on the form. In this case, we are going to ask the people filling in the form if they are new customers or old customers. To do that you will generate a new tag. When you are done it should look like below:</p>
<div id="attachment_744" class="wp-caption aligncenter" style="width: 1282px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; display: block; margin-right: auto; margin-left: auto;"><img src="http://www.statstory.com/wp-content/uploads/2013/04/contact7-adding-custom-variable.png" alt="contact7 adding custom variable Google Analytics, Custom Variables And Contact Form 7" width="1272" height="472" class="size-full wp-image-744" title="Google Analytics, Custom Variables And Contact Form 7" /><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">contact7-adding-custom-variable</p></div>
<p>The main thing to ensure is you give your new form item an ID, which in this case with be &#8220;Lead_Type&#8221;. It will look like this<br />
<img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/04/contact7-adding-custom-variable_lead_type.png" alt="contact7 adding custom variable lead type Google Analytics, Custom Variables And Contact Form 7" width="600" height="314" class="aligncenter size-full wp-image-747" title="Google Analytics, Custom Variables And Contact Form 7" /></p>
<p>Make sure you add the code noted at the bottom of this screen to the left in the form so users can fill it in for you. You also want to make sure you add it to your email to, so make sure to add those tags to. Once your form is done, you are ready for some code</p>
<p><strong>On to the code</strong><br />
Now that you are done, it&#8217;s time to add the code to make this work to the &#8220;Additional Settings&#8221; box using the &#8220;ok_on_send&#8221;. Just copt and paste below</p>
<pre class="brush: php; title: ; notranslate">
on_sent_ok: &quot;var lead = document.getElementById('Lead_Type').value;_gaq.push(['_setCustomVar',1,'Lead Type',''+ lead+'',1]);&quot;
</pre>
<p>When done this is how it should look like below</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/04/additional_settings_ok_on_send.png" alt="additional settings ok on send Google Analytics, Custom Variables And Contact Form 7" width="734" height="202" class="aligncenter size-full wp-image-748" title="Google Analytics, Custom Variables And Contact Form 7" /></p>
<p>So what does this code do? First, it makes sure that the user email meets the requirements, for example if you have a captcha, or that the email address is well formed. If all is okay, the Javascript will search for the value of &#8220;Lead_Type&#8221;, which we have assigned to a variable called &#8220;lead&#8221;. The final step is Google Analytics, will grab the value of &#8220;lead&#8221; and insert it into Google Analytics via a custom variable. We have in this case used slot 1, and we have set the session level at Visitor level (denoted by the number one)/ This means as long as the cookie remains, your visitor will have this variable assigned to them for two years. In some cases, it might make sense to use at the session level, which means the final number should be changed to &#8220;2&#8243; or Page Level, which is &#8220;3&#8243;. It really all depends on your needs and strategy. If you are interested to learn more on Custom Variables, you can read our article on them <a href="http://www.statstory.com/custom-variables-in-google-analytics/" title="Custom Variables">here</a>.  </p>
<p><strong>Final Thoughts</strong><br />
So there you have it. If you are able to make it happen in Javascript, you can make the data available for Google. Just make sure you respect their rules. Happy tracking!</p>
<p><a href="http://www.statstory.com/google-analytics-custom-variables-and-contact-form-7/">Google Analytics, Custom Variables And Contact Form 7</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.statstory.com/google-analytics-custom-variables-and-contact-form-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tracking Clicks and Impressions In Piwik Analytics</title>
		<link>http://www.statstory.com/tracking-clicks-and-impressions-in-piwik-analytics/</link>
		<comments>http://www.statstory.com/tracking-clicks-and-impressions-in-piwik-analytics/#comments</comments>
		<pubDate>Thu, 14 Mar 2013 00:22:27 +0000</pubDate>
		<dc:creator>Adrian Speyer</dc:creator>
				<category><![CDATA[Piwik]]></category>
		<category><![CDATA[Internal banner]]></category>
		<category><![CDATA[track impressions]]></category>

		<guid isPermaLink="false">http://www.statstory.com/?p=706</guid>
		<description><![CDATA[Tracking Clicks and Impressions with Google Analytics As you may or may not know, when you use Google Analytics you cannot track clicks or impressions of ads on your site. In order to do so, you need to employ an ad server. As such, it&#8217;s not really a big, deal, but if you are like [...]<p><a href="http://www.statstory.com/tracking-clicks-and-impressions-in-piwik-analytics/">Tracking Clicks and Impressions In Piwik Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></description>
				<content:encoded><![CDATA[<p><strong>Tracking Clicks and Impressions with Google Analytics</strong><br />
As you may or may not know, when you use Google Analytics you cannot track clicks or impressions of ads on your site. In order to do so, you need to employ an ad server. As such, it&#8217;s not really a big, deal, but if you are like me and you like to have all the data in one place, it can become a pain. I have created a solution for this problem, for <a href="http://www.statstory.com/tracking-clicks-and-impressions-in-google-analytics/" title="Clicks and Impressions Google Analytics">Google Analytics</a> users, but I did not want to stop there. I wanted to share my code with users of Piwik. This is not only because I think Piwik rocks. With Piwik&#8217;s powerful PHP API, you can create some awesome things as well. </p>
<p><strong>The basic tracking</strong><br />
So how do you go about creating a tracker for clicks and impressions for Piwik. You use Custom Variables of course! I covered the basics of those over <a href="http://www.statstory.com/custom-variables-in-piwik/" title="Custom Variables in Piwik">here</a>, but in short, the custom variables in Piwik looks like below:</p>
<pre class="brush: php; title: ; notranslate">
piwikTracker.setCustomVariable(&quot;INDEX&quot;, &quot;NAME&quot;, &quot;VALUE&quot;, &quot;SCOPE&quot;);
</pre>
<p>INDEX: 1-5 slots<br />
NAME: This is the group name<br />
VALUE: The Label for the group<br />
SCOPE: This you have choice of Page or Visit.</p>
<p>In Piwik, we would build the clicks to look like this</p>
<pre class="brush: php; title: ; notranslate">piwikTracker.setCustomVariable(1, &quot;BANNERNAME&quot;, &quot;click&quot;, &quot;page&quot;);</pre>
<p>And impressions will be created like so:</p>
<pre class="brush: php; title: ; notranslate">piwikTracker.setCustomVariable(1, &quot;BANNERNAME&quot;, &quot;impressions&quot;, &quot;page&quot;);</pre>
<p>As you may notice, we do not have a slot for Cost per Click or Cost per 1000. We can get creative and append to the Name Value like so</p>
<pre class="brush: php; title: ; notranslate">piwikTracker.setCustomVariable(1, &quot;BANNERNAME-Click&quot;, &quot;1.00&quot;, &quot;page&quot;);</pre>
<p><strong>So what&#8217;s the full code look like?</strong><br />
As we saw with the Google solution, we will use an invisible GIF to fire to track impressions. So now we put all together so it can work for Piwik:</p>
<pre class="brush: php; title: ; notranslate">
&lt;a href=&quot;http://localhost/someurl&quot; onClick=&quot;piwikTracker.setCustomVariable('1','BANNERNAME', 'Click', 'page'); piwikTracker.trackPageView();&quot; &gt;
 &lt;img src=&quot;http://localhost/someurltoapic.jpg&quot; alt=&quot;SOME ALT TEXT&quot; border=&quot;0&quot;/&gt;&lt;/a&gt;
 &lt;img  width=0 height=0 src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==&quot; onload=&quot;piwikTracker.setCustomVariable('2','BANNERNAME', 'Impression', 'page');piwikTracker.trackPageView();&quot;&gt;
</pre>
<p>You will obviously need to change &#8220;http://localhost/someurl&#8221; to be the link where you want users to go and &#8220;http://localhost/someurltoapic.jpg&#8221; for the appropriate image, but this will work right out of the box except&#8230;</p>
<p><strong>Some other Modifications are needed and notes</strong><br />
To make custom variables work for you you will need to ensure that your Piwik Tracking code is the <HEAD> not at the </BODY>. Also as Piwik only allow you to have 1 INDEX slot per page view (for now) so that means maximum number of ads you should run with this is 2 per page. Now that you are up and running, you will have a custom variables report for clicks and impressions right in your Piwik install. Below is a screen shot of how it will look:</p>
<p><a href="http://www.statstory.com/wp-content/uploads/2013/03/click-impression-piwik.png"><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/03/click-impression-piwik.png" alt="click impression piwik Tracking Clicks and Impressions In Piwik Analytics" width="547" height="862" class="aligncenter size-full wp-image-708" title="Tracking Clicks and Impressions In Piwik Analytics" /></a></p>
<p>You can also create your own script with the <a href="http://piwik.org/docs/analytics-api/reference/" title="Piwik Analytics API">Piwik API</a>, to get the Clicks and Impressions in the format you choose. Like below</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/03/banner-impressiom-table.png" alt="banner impressiom table Tracking Clicks and Impressions In Piwik Analytics" width="288" height="137" class="aligncenter size-full wp-image-709" title="Tracking Clicks and Impressions In Piwik Analytics" /></p>
<p>You can get this script <a href="http://www.statstory.com/scripts/piwik-banner-impression.rar" title="Piwik API Banner">here</a> to play with. It pulls the latest from your custom variables that contain the word Banner.</p>
<p><strong>Creativity Time</strong><br />
Other than this, the sky the limit for your creativity. For example, you can create a PHP array and rotating banners. To help your creative juices, I have come up with a script that does just that. You can get it for free right <a href="http://www.statstory.com/scripts/banner-rotate-click-impressions-Piwik-v2.rar" title="Tracking Clicks &#038;  Impressions  With Piwik Analytics">here</a>. I hope you find this solution helpful or if you appreciate it, please don&#8217;t be shy to share this article with your friends. Also if you also want check out the <a href="http://www.statstory.com/tracking-clicks-and-impressions-in-google-analytics/" title="Google Analytics Impressions and Clicks">Google Analytics solution</a> to track impressions and clicks.</p>
<p><a href="http://www.statstory.com/tracking-clicks-and-impressions-in-piwik-analytics/">Tracking Clicks and Impressions In Piwik Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.statstory.com/tracking-clicks-and-impressions-in-piwik-analytics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tracking Clicks and Impressions In Google Analytics</title>
		<link>http://www.statstory.com/tracking-clicks-and-impressions-in-google-analytics/</link>
		<comments>http://www.statstory.com/tracking-clicks-and-impressions-in-google-analytics/#comments</comments>
		<pubDate>Thu, 14 Mar 2013 00:21:04 +0000</pubDate>
		<dc:creator>Adrian Speyer</dc:creator>
				<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Internal Ads]]></category>
		<category><![CDATA[Tracking Impressions]]></category>

		<guid isPermaLink="false">http://www.statstory.com/?p=700</guid>
		<description><![CDATA[Internal Banner Ads and Google Analytics One thing of the many things that Google does well is integrate with Google Adwords. No other Analytics package can really compare with the ease to which it does this because they are so well inter-linked. So, to me, it has always been a shame, Google Analytics does not [...]<p><a href="http://www.statstory.com/tracking-clicks-and-impressions-in-google-analytics/">Tracking Clicks and Impressions In Google Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></description>
				<content:encoded><![CDATA[<p><strong>Internal Banner Ads and Google Analytics</strong><br />
One thing of the many things that Google does well is integrate with Google Adwords. No other Analytics package can really compare with the ease to which it does this because they are so well inter-linked. So, to me, it has always been a shame, Google Analytics does not come with an easy way to track on-site banners or advertising. For example if you want to calculate how many clicks a banner has on one of your pages or if you want to know how many impressions an advert has, you are basically out of luck. If you have a Magento Eneterprise site with banner ads or if you have a simple site that sells space you are pretty much have couple of choices: Install an AdServer, like <a href="http://www.openx.com/" title="OpenX">OpenX</a> or some other service. The reality is, though, you have Google Analytics for a reason: To track user behavior. Why now pile another tool into the mix? </p>
<p><strong>Tracking Banner Clicks and Impressions with Google Analytics</strong><br />
With some creative tinkering and leveraging Event Tracking, I am proud to share with you a great way to track banner ads for your site. Not only can you get the number of clicks (which you could already get), I have found a way for you to also calculate the number of impressions of a banner. Also with the beauty of events, you can assign a value, so you can charge a cost per impressions or a cost per click and easily create an easy way to charge your customer. Even better with Event tracking you can create goals, custom reports, filter to a profile and even more.</p>
<p>Below is the code that does all the magic</p>
<pre class="brush: php; title: ; notranslate">
&lt;a href=&quot;http://localhost/someurl&quot; onClick=&quot;_gaq.push(['_trackEvent', 'Banner', 'Click', 'BANNERNAME',1.00,true]);&quot; &gt; &lt;img style=&quot;border: 0px&quot; src=&quot;http://localhost/someurltoapic.jpg&quot; alt=&quot;SOMEALTEXT&quot; /&gt;&lt;/a&gt;
&lt;img width=0 height=0 src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==&quot; onload=&quot;_gaq.push(['_trackEvent', 'Banner', 'Impression', 'BANNERNAME',2.00,true]);&quot;/&gt;
</pre>
<p><strong>What does the code do? </strong><br />
The first bit of the code, you want to replace &#8220;http://localhost/someurl&#8221; with the link you want users to visit. Then we hit the event tracking portion which looks like  this</p>
<pre class="brush: php; title: ; notranslate">
_gaq.push(['_trackEvent', 'Banner', 'Click', 'BANNERNAME',1.00,true]);
</pre>
<p>As you recall from an <a href="http://www.statstory.com/tracking-events-in-google-analytics/" title="Event Tracking In Google Analytics">earlier article</a>, an event is composed of few bits of information:</p>
<pre class="brush: php; title: ; notranslate">
_gaq.push(['_trackEvent' ('category', 'action', 'label', 'value', 'noninteraction']);
</pre>
<p>So for us, it works as the following:</p>
<ul>
<li>Category will be &#8220;Banner&#8221;</li>
<li>Action label for this is &#8220;Click&#8221;</li>
<li>Label should be the &#8220;Banner Name&#8221; and possbily the location of the ad (top) or size (728&#215;90)</li>
<li>Value can be left blank or 0. If you like, it can also be your cost per click (CPC)</li>
<li>Non-Interaction, we have set as true. As we do not want this interaction to interfere with the bounce rate. As <a href="https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#non-interaction)" title="Non-Interaction Guide">Google notes</a>.</li>
</ul>
<p>The next bit of code tracks the impression, by sending an event when a fake transparent gif on load. The code looks as follows</p>
<pre class="brush: php; title: ; notranslate">
_gaq.push(['_trackEvent', 'Banner', 'Impression', 'BANNERNAME',2.00,true])
</pre>
<p>So for us, it will almost be same as the set up for clicks:</p>
<ul>
<li>Category will be &#8220;Banner&#8221; like before</li>
<li>Action label for this is &#8220;Impression&#8221;</li>
<li>Label should be the same &#8220;Banner Name&#8221; as before, as well as possbily the location of the ad (top) or size (728&#215;90)</li>
<li>Value can be left blank or 0. If you like, it can also be your cost per cost per 1000 (CPM)</li>
<li>Non-Interaction, we have set as true.</li>
</ul>
<p>Once done it will provide you a lovely report in Google Analytics like below:</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/03/click-impression-google.png" alt="click impression google Tracking Clicks and Impressions In Google Analytics " width="419" height="310" class="aligncenter size-full wp-image-703" title="Tracking Clicks and Impressions In Google Analytics " /></p>
<p>Now you can create a custom report, goals, email reports, or even a profile filtered just for ads.You can even get more creative with array and rotating banner, and get totally rocking with tracking banner ads and impressions. To help your creative juices, I have come up with a script that does just that. You can get it for free right <a href="http://www.statstory.com/scripts/banner-rotate-click-impressions-GA-v2.rar" title="Tracking Clicks &#038;  Impressions  With Google Analytics">here</a>. </p>
<p><strong>A couple of final words</strong><br />
While I don&#8217;t think it should be an issue for most site, for high traffic site I recommend you read Google Analytics <a href="https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#implementationConsiderations" title="Implementation Considerations">Implementation Considerations about events</a>. In short, Google Analytics records, the first 10 event hits in a session sent to Google Analytics are tracked immediately. Thereafter tracking is rate limited, so it can only record one event hit per second. As the number of events in a session approaches the collection limit, additional events might not be tracked. For this reason, I also recommend you check out <a href="http://www.statstory.com/tracking-clicks-and-impressions-in-piwik-analytics/" title="Impressions and Clicks in Piwik">my implementation for this solution in Piwik</a>. With Piwik, you can use their PHP API to create a lovely report including CTR and customize it to your needs. I also have one favor to ask, if you found this solution helpful or if you appreciate it, please don&#8217;t be shy to share this article with your friends. It&#8217;s wonderful readers like you that make sharing these solutions worthwhile.</p>
<p><a href="http://www.statstory.com/tracking-clicks-and-impressions-in-google-analytics/">Tracking Clicks and Impressions In Google Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.statstory.com/tracking-clicks-and-impressions-in-google-analytics/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Change Language of Piwik Opt-Out Iframe</title>
		<link>http://www.statstory.com/change-language-of-piwik-opt-out-iframe/</link>
		<comments>http://www.statstory.com/change-language-of-piwik-opt-out-iframe/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 03:10:34 +0000</pubDate>
		<dc:creator>Adrian Speyer</dc:creator>
				<category><![CDATA[Piwik]]></category>
		<category><![CDATA[Privacy Iframe]]></category>

		<guid isPermaLink="false">http://www.statstory.com/?p=627</guid>
		<description><![CDATA[Protecting User Privacy On your website, you can add an easy way for your visitors to &#8220;opt-out&#8221; of being tracked by your Piwik install. By default, all of your website visitors are tracked. With Piwik iframe, you get some simple code to add to your privacy page, to let users opt out. When finished it [...]<p><a href="http://www.statstory.com/change-language-of-piwik-opt-out-iframe/">Change Language of Piwik Opt-Out Iframe</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></description>
				<content:encoded><![CDATA[<p><strong>Protecting User Privacy</strong><br />
On your website, you can add an easy way for your visitors to <a href="http://piwik.org/privacy/#toc-step-5-optional-privacy-preferences" title="Privacy">&#8220;opt-out&#8221; of being tracked by your Piwik install</a>. By default, all of your website visitors are tracked. With Piwik iframe, you get some simple code to add to your privacy page, to let users opt out. When finished it will look like this:</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/03/privacy-checkbox1.png" alt="privacy checkbox1 Change Language of Piwik Opt Out Iframe" width="762" height="77" class="aligncenter size-full wp-image-697" title="Change Language of Piwik Opt Out Iframe" /></p>
<p>To find the code go to Settings > Privacy.If a user opts-out by clicking on the checkbox in Privacy iFrame, Piwik will set a new cookie called: &#8220;piwik_ignore&#8221;. Now with the cookie set, this user will not be tracked. </p>
<p><strong>Opt-Out in Your Language</strong><br />
If you need to change the language of the iframe for optout for users, all you need to do is change the language. For example below if the code for English:</p>
<pre class="brush: php; title: ; notranslate">
&lt;iframe frameborder=&quot;no&quot; width=&quot;600px&quot; height=&quot;200px&quot; src=&quot;https://localhost/index.php?module=CoreAdminHome&amp;action=optOut&amp;language=en&quot;&gt;&lt;/iframe&gt;
</pre>
<p> Just change &#8220;en&#8221; to &#8220;fr&#8221; as below</p>
<pre class="brush: php; title: ; notranslate">
&lt;iframe frameborder=&quot;no&quot; width=&quot;600px&quot; height=&quot;200px&quot; src=&quot;https://localhost/index.php?module=CoreAdminHome&amp;action=optOut&amp;language=fr&quot;&gt;&lt;/iframe&gt;
</pre>
<p>This comes in handy if you have a bilingual site and want people to opt out in their language, but keep your backend Piwik install in one of your choice. </p>
<p><a href="http://www.statstory.com/change-language-of-piwik-opt-out-iframe/">Change Language of Piwik Opt-Out Iframe</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.statstory.com/change-language-of-piwik-opt-out-iframe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Avoid Bots When Using Image Tracking in Piwik Analytics</title>
		<link>http://www.statstory.com/how-to-avoid-bots-when-using-image-tracking-in-piwik-analytics/</link>
		<comments>http://www.statstory.com/how-to-avoid-bots-when-using-image-tracking-in-piwik-analytics/#comments</comments>
		<pubDate>Sat, 09 Mar 2013 20:33:27 +0000</pubDate>
		<dc:creator>Adrian Speyer</dc:creator>
				<category><![CDATA[Piwik]]></category>

		<guid isPermaLink="false">http://www.statstory.com/?p=604</guid>
		<description><![CDATA[Javascript Free Tracking There are a couple of ways to track your visitors, without javascript, for example using the Piwik PHP API. But sometimes, you just need a quick fix or a simple solution. In case you were not aware, by default the standard Tracking Tag for Piwik uses Javascript. This means, Piwik will only [...]<p><a href="http://www.statstory.com/how-to-avoid-bots-when-using-image-tracking-in-piwik-analytics/">How To Avoid Bots When Using Image Tracking in Piwik Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></description>
				<content:encoded><![CDATA[<p><strong>Javascript Free Tracking</strong></p>
<p>There are a couple of ways to track your visitors, without javascript, for example using the <a href="http://piwik.org/docs/tracking-api/#toc-how-to-use-the-php-tracker-api-example" title="PHP Tracker">Piwik PHP API</a>. But sometimes, you just need a quick fix or a simple solution. In case you were not aware, by default the standard Tracking Tag for Piwik uses Javascript. This means, Piwik will only track visitors with Javascript enabled in their web browser. If you happen to be in a niche, where lots of users have noscript enabled, you will lose a percentage of your visitors. Out of the box Piwik offers a way to track users with Javascript disabled. The code looks like below. </p>
<pre class="brush: php; title: ; notranslate">&lt;noscript&gt;&lt;p&gt;&lt;img src=&quot;http://localhost/piwik.php?idsite=1&amp;rec=1&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;&lt;/noscript&gt;</pre>
<p>With this code, you will get only basic information of a hit to your website. You will not get custom variables, you will not get technical information about the user (i.e. Browser, Screen Size ect). And you will also face a bigger issue&#8230;</p>
<p><strong>Rise of the Bots</strong><br />
Bots. Yes, those lovely creatures. Well some are not bad, such as Google or Bing who crawl our site and help with getting you traffic. Nevertheless, they can also cause your trouble, by triggering your image tracker and in a really bad case cause server slowdown. </p>
<p><strong>Solution</strong><br />
Thankfully there is a simple solution, you can modify the code. All you need to do is replace the standard image tracking code with the below:</p>
<pre class="brush: php; title: ; notranslate">
&lt;noscript&gt;
&lt;?php
if (preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'])) {
//do not fire tracker  
}
  else {?&gt;
&lt;!-- Piwik Image Tracker --&gt;
&lt;img src=&quot;http://localhost/piwik/piwik.php?&amp;idsite=1&amp;amp;rec=1&amp;urlref&amp;_cvar={&amp;quot;5&amp;quot;:[&amp;quot;Non Bot&amp;quot;,&amp;quot;No Javascript&amp;quot;]}&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;
&lt;!-- End Piwik --&gt;
 &lt;?php }?&gt;
&lt;/noscript&gt;
</pre>
<p>All you need to do is change the url and the siteid to the appropriate information. After that, this code will start tracking only when a user has noscript enabled and their user agent does not meet one of the patterns listed (i.e bot). It will also create a custom variable in slot 5 with information that the visit was a Javascript disabled/non-bot visit. If there are things you want to add or delete to the image tracking, you can read all the options at the Piwik wesbite and <a href="http://piwik.org/docs/tracking-api/#toc-two-tracking-methods-image-tracking-or-using-the-api" title="Image Tracking">learn more</a> about customizing the image tracker.</p>
<p><a href="http://www.statstory.com/how-to-avoid-bots-when-using-image-tracking-in-piwik-analytics/">How To Avoid Bots When Using Image Tracking in Piwik Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.statstory.com/how-to-avoid-bots-when-using-image-tracking-in-piwik-analytics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Google Analytics</title>
		<link>http://www.statstory.com/debugging-google-analytics/</link>
		<comments>http://www.statstory.com/debugging-google-analytics/#comments</comments>
		<pubDate>Sat, 09 Mar 2013 16:03:57 +0000</pubDate>
		<dc:creator>Adrian Speyer</dc:creator>
				<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[debugging google analytics]]></category>

		<guid isPermaLink="false">http://www.statstory.com/?p=125</guid>
		<description><![CDATA[The Art of Debugging Depending on your view, debugging Google Analytics can be fun, interesting or frustrating. One thing we can agree on, is that it can be time consuming. Imagine, you just spent hours tagging a site with custom code/events/custom variables and then you go to your Google Analytics and you have no data! [...]<p><a href="http://www.statstory.com/debugging-google-analytics/">Debugging Google Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></description>
				<content:encoded><![CDATA[<p><strong>The Art of Debugging</strong><br />
Depending on your view, debugging Google Analytics can be fun, interesting or frustrating. One thing we can agree on, is that it can be time consuming. Imagine, you just spent hours tagging a site with custom code/events/custom variables and then you go to your Google Analytics and you have no data! ACK&#8230;What can you do? Welcome to the art of debugging Google Analytics. </p>
<p><strong>Basic Steps</strong><br />
One of things that can happen, with many CMS&#8217;s such as WordPress is Plugins, like SuperCache, will have a cache of the page, and your code while uploaded, is not actually live. Make sure you have cleared your cache of your site. While at it, I would also clear your browser cache. Personally one of my favourite tools for debugging is Google Chrome Incognito mode. When you use it, you get a new session. </p>
<p>Another important step would be to make sure you check you do not have Adblock, Noscript or Google Analytics Plugin enabled. Sometimes, when I am working on a site, I will enable this to not count my visits. When debugging you want to make sure this is off.</p>
<p>The final of the basic steps is to use <a href="https://support.google.com/analytics/bin/answer.py?hl=en&#038;answer=1638635&#038;topic=1638563&#038;rd=1" title="Google Analytics Real-Time">Google Analytics Real-Time</a>. With this tool you can see if your visits are even being seen instantly. Remember, it can still take time for your visits to show in the reporting tabs, but if Google Analytics sees your visits in realtime, all is not lost. Now the issue could be a custom variable or an event code is not firing properly. If after some time (like 2 hours) you no do see data, make sure you refresh your report. Google Analytics themselves added a cache feature which might be the cause of your issues. You will see the option to refresh you report at the bottom of report pages in the right bottom corner.</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/03/refersh-reports.png" alt="refersh reports Debugging Google Analytics" width="535" height="176" class="aligncenter size-full wp-image-657" title="Debugging Google Analytics" /></p>
<p>If all of the above does work, collect $200 and pass go. Otherwise let&#8217;s more to debugging tools.</p>
<p><strong>Debugging Tools</strong></p>
<p>The most important (and almost only) tool you will need to troubleshoot your Google Analytics install is <a href="https://chrome.google.com/webstore/detail/jnkmfdileelhofjcijamephohjechhna" title="Google Analytics Debugger">Google Analytics Debugger Chrome Extension</a>. When installed, this tool will print out the information sent by Google Analytics to Google from the code on your site. Once you install the plugin, make sure you have all other plugins blocking Google Analytics off, or use an Icognitio tab, and click the Google Analytics Icon:</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/03/google-analytics-debug-button.jpg" alt="google analytics debug button Debugging Google Analytics" width="161" height="94" class="aligncenter size-full wp-image-658" title="Debugging Google Analytics" /></p>
<p>To see the information open your Javascript Console in Google Chome (CTRL+SHIFT+J), and you will get all get messages, including any errors and warnings, as well as a detailed breakdown of each tracking beacon sent to Google Analytics. Below is an example of output on this site:</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/03/google-analytics-debug-beacon-1024x406.jpg" alt="google analytics debug beacon 1024x406 Debugging Google Analytics" width="600" height="237" class="aligncenter size-large wp-image-659" title="Debugging Google Analytics" /></p>
<p>This will tell you right away if you event has fired. If the data is not even being sent to Google, then you can see where in the code the issue lies. Maybe Events are tracking, but Custom Variables are not. Maybe some custom variables are showing and some are not. Honestly, the Chrome Extension will save you hours of work very quickly. I should note, it works only on the ga.js tracker, so if you have moved to Universal Analytics, you will need to  use Firebug. Also if you do not want to use Chrome, here are some alternatives <a href="https://developers.google.com/analytics/resources/articles/gaTrackingTroubleshooting#debuggingTools" title="Other suggestions">suggested by Google</a>, but to honest, use the Chrome extension. You won&#8217;t regret it.</p>
<p><strong>Remain Calm</strong><br />
Sometimes it becomes hard to figure out the issue with your Google Analytics, but there has never been an issue that Real-Time Google Analytics and the  Google Chrome Extension has not been able to help me solve. All you need is some patience and to remain clam. Eventually you will find the issue and be able to continue measuring your visitors on your website. Good Luck!<br />
<img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/03/keep-calm.png" alt="keep calm Debugging Google Analytics" width="426" height="600" class="aligncenter size-full wp-image-655" title="Debugging Google Analytics" /></p>
<p><a href="http://www.statstory.com/debugging-google-analytics/">Debugging Google Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.statstory.com/debugging-google-analytics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Extra Data Point in Piwik Custom Variables</title>
		<link>http://www.statstory.com/an-extra-data-point-in-piwik-custom-variables/</link>
		<comments>http://www.statstory.com/an-extra-data-point-in-piwik-custom-variables/#comments</comments>
		<pubDate>Fri, 22 Feb 2013 02:58:23 +0000</pubDate>
		<dc:creator>Adrian Speyer</dc:creator>
				<category><![CDATA[Piwik]]></category>
		<category><![CDATA[custom variables]]></category>

		<guid isPermaLink="false">http://www.statstory.com/?p=598</guid>
		<description><![CDATA[Sometimes when you are working with Piwik Custom Variables, you need an extra slot for data. Below is some quick code to add an extra value to your custom variables: In this scenario, $variable1 and $variable2 are whatever you want. It could be a variable for a topic and a landing page. It could be [...]<p><a href="http://www.statstory.com/an-extra-data-point-in-piwik-custom-variables/">An Extra Data Point in Piwik Custom Variables</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></description>
				<content:encoded><![CDATA[<p>Sometimes when you are working with <a href="http://www.statstory.com/custom-variables-in-piwik/" title="Piwik Custom Variables">Piwik Custom Variables</a>, you need an extra slot for data. Below is some quick code to add an extra value to your custom variables:</p>
<pre class="brush: php; title: ; notranslate">
{..}
piwikTracker.setCustomVariable (1, &quot;Category&quot;,&quot;Data1 = $variable1&quot;+ &quot;| Data2 = $Variable2&quot;, &quot;page&quot;);
{..}
</pre>
<p>In this scenario, $variable1 and $variable2 are whatever you want. It could be a variable for a topic and a landing page. It could be country and language. It can be any two data points you want associated.</p>
<p>So in the end full code will look like this</p>
<pre class="brush: php; title: ; notranslate">
&lt;!-- Piwik --&gt; 
&lt;script type=&quot;text/javascript&quot;&gt;
var pkBaseURL = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://localhost/piwik/&quot; : &quot;http://localhost/piwik/&quot;);
document.write(unescape(&quot;%3Cscript src='&quot; + pkBaseURL + &quot;piwik.js' type='text/javascript'%3E%3C/script%3E&quot;));
&lt;/script&gt;&lt;script type=&quot;text/javascript&quot;&gt;
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + &quot;piwik.php&quot;, 1);
piwikTracker.setCustomVariable (1, &quot;Category&quot;,&quot;Data1 = $variable1&quot;+ &quot;| Data2 = $Variable2&quot;, &quot;page&quot;);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
&lt;/script&gt;&lt;noscript&gt;&lt;p&gt;&lt;img src=&quot;http://localhost/piwik/piwik.php?idsite=1&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;&lt;/noscript&gt;
&lt;!-- End Piwik Tracking Code --&gt;
</pre>
<p>Output will look like this:</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/02/custom-variables-two-slots.png" alt="custom variables two slots An Extra Data Point in Piwik Custom Variables" width="461" height="188" class="aligncenter size-full wp-image-600" title="An Extra Data Point in Piwik Custom Variables" /></p>
<p><a href="http://www.statstory.com/an-extra-data-point-in-piwik-custom-variables/">An Extra Data Point in Piwik Custom Variables</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.statstory.com/an-extra-data-point-in-piwik-custom-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Many Users Block Your Ads? Find Out!</title>
		<link>http://www.statstory.com/how-many-users-block-your-ads-find-out/</link>
		<comments>http://www.statstory.com/how-many-users-block-your-ads-find-out/#comments</comments>
		<pubDate>Fri, 22 Feb 2013 00:01:03 +0000</pubDate>
		<dc:creator>Adrian Speyer</dc:creator>
				<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Piwik]]></category>
		<category><![CDATA[Ad Blocking]]></category>
		<category><![CDATA[Adblock]]></category>

		<guid isPermaLink="false">http://www.statstory.com/?p=583</guid>
		<description><![CDATA[Your Visitors Block Ads, But How Many? Have you ever been curious to know how many people are blocking ads on your site? I had try to measure this in the past, but today I have a much more elegant solution. Why Bother Tracking If People Don&#8217;t See Ads? One of the reasons I wanted [...]<p><a href="http://www.statstory.com/how-many-users-block-your-ads-find-out/">How Many Users Block Your Ads? Find Out!</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></description>
				<content:encoded><![CDATA[<p><strong>Your Visitors Block Ads, But How Many?</strong><br />
Have you ever been curious to know how many people are blocking ads on your site? I had try to measure this in the past, but today I have a much more elegant solution. </p>
<p><strong>Why Bother Tracking If People Don&#8217;t See Ads?</strong><br />
One of the reasons I wanted to know how much adblocking was occurring is to make the determination if serving ads was even worthwhile. Sure if you have Adsense, you get a feel for the revenue, but do you know how many extra eyeballs never even see the ads? Maybe 90% of your users block ads? Maybe you need to get creative in your advertising? Maybe you should remove ads altogether if you need a source of revenue?</p>
<p><strong>Some Caveats About Ad Block Tracking</strong><br />
If a user is intent on not being tracked, this solution will not work. In other words, if they are using no script or blocking trackers all together, they will not be counted. There are work-arounds for this, but there is a whole new set of problems with tracking noscript referrers. If you are not aware, bots do not read javascript so your log/analytics could get swamped by hits from bots, crawlers and other beings that may or may not be real. Nevertheless, taking this into account and having an adblock number can still give you some interesting insights about your visitors.</p>
<p><strong>Choose your solution</strong><br />
No matter your analytics solution, either Google Analytics or Piwik Analytics, below is how you would find out if users are blocking ads. </p>
<p><strong>First Step: jQuery</strong><br />
Please make sure you have your Google or Piwik tracking installed and working. You will also need the jQuery Library on your site. The easiest way<br />
to add this is use the Google hosted jQuery Library. Just add this code to your site:</p>
<pre class="brush: php; title: ; notranslate">&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&quot;&gt;&lt;/script&gt;</pre>
<p><strong>Second Step: Your Ads</strong><br />
The next step is to mark up your Ads div. If you don&#8217;t want to mark up the div, or are not sure how to, just add the below to anywhere on the page.</p>
<pre class="brush: php; title: ; notranslate">&lt;div class=&quot;adsense&quot;&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;</pre>
<p><strong>Third Step: Tracking &#8211; Google Analytics</strong></p>
<p>For Google Analytics you can do the tracking as an event or a custom variable. Just make sure the div is the same as denoted in this portion of the code: <code>if ($(".adsense")</code>. If you use our default implementation or your div name is &#8220;adsense&#8221; you are fine.</p>
<p>Custom Variable Code</p>
<pre class="brush: php; title: ; notranslate">
/* Adblock Check */ 
$(document).ready(checkAds());

function checkAds() {
        if ($(&quot;.adsense&quot;).height() == &quot;0&quot;) {
        document.write(&quot;&lt;script&gt; _gaq.push(['_setCustomVar', 5, 'Adblock','Blocked',2]);&lt;\/sc&quot; + &quot;ript&gt;&quot;);}    
		else
		{
		document.write(&quot;&lt;script&gt; _gaq.push(['_setCustomVar', 5, 'Adblock','UnBlocked',2]);&lt;\/sc&quot; + &quot;ript&gt;&quot;);}	
		}	
/* End Adblock Check */ 
</pre>
<p>Here is the Adblock Event Tracking Code:</p>
<pre class="brush: php; title: ; notranslate">
&lt;!--Adblock Check--&gt;
&lt;script&gt;
$(document).ready(checkAds());

function checkAds() {
        if ($(&quot;.adsense&quot;).height() == &quot;0&quot;) {
        document.write(&quot;&lt;script&gt;_gaq.push(['_trackEvent', 'Adblock', 'Blocked', 'true',,true]);&lt;\/sc&quot; + &quot;ript&gt;&quot;);}    
		else
		{
		document.write(&quot;&lt;script&gt;_gaq.push(['_trackEvent', 'Adblock', 'Unblocked', 'false',,true]);&lt;\/sc&quot; + &quot;ript&gt;&quot;);}	
		}	
&lt;/script&gt;
&lt;!--End Adblock Check--&gt;
</pre>
<p>Personally I would use the custom variable option. The benefit of using custom variables is you can easily use it to see behavioural differences of those that block ads vs. those who do not. Only do this if you have the slots in Google Analytics. If you were not aware, the free version of Google Analytics limits you to 5 custom variable slots per session. To account for this, I have set the code to take slot 5. If you need all 5 custom variable slots, use the event tracking. Don&#8217;t cry if you have to use the events code. You can still see how Adblock visits affect your traffic by using Advanced Segements. You can see here for more details on how to use <a href="http://www.statstory.com/events-advanced-segments-in-google-analytics/" title="Advanced Segments and Events">Advanced Segments and Events</a>. </p>
<p>Sometimes, when you are using custom variables, it&#8217;s hard to place it within the core Google Tracking Code. If your adblocking check must happen later in the page, after the initial call to <code>_gaq.push(['_trackPageview']);</code>, there are two solutions: One is to use a virtual pageview, which you would filter out of the account (i.e. <code>_gaq.push(['_trackPageview', '/fakepage]);</code> ). The reason you would do this is to reinstantiate the tracker, by causing a tracking GIF request. This in turn will help to deliver the custom variable to your Google Analytics. The other, solution to refire the tracking GIF request is to call an event after you set the custom variable. Below is the sample code to do that.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!--GA Adblock Check--&gt;
&lt;script&gt;
$(document).ready(checkAds());
function checkAds() {
if ($(&quot;.adsense&quot;).height() == &quot;0&quot;) {
document.write(&quot;&lt;script&gt;_gaq.push(['_setCustomVar',5,'Adblock','true',2]); _gaq.push(['_trackEvent','Adblock','true']);&lt;\/sc&quot; + &quot;ript&gt;&quot;);
}    
else
{
document.write(&quot;script&gt;_gaq.push(['_setCustomVar',5,'Adblock','false',2]); _gaq.push(['_trackEvent','Adblock','false']);&lt;\/sc&quot;+&quot;ript&gt;&quot;);
}	
}	
&lt;/script&gt;
&lt;!--End Adblock Check--&gt;
</pre>
<p>Calling an event after the custom variable is set is also a preferred method noted by Google in their <a href="https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables" title="Google Custom Variation Docs">Custom Variable documentation</a>.</p>
<p><strong>Third Step: Tracking &#8211; Piwik Analytics</strong><br />
For Piwik Analytics the tracking is done as a custom variable. Just make sure the div is the same as denoted in this portion of the code: <code>if ($(".adsense")</code>. If you use our default implementation or your div name is &#8220;adsense&#8221; you are fine. Like Google Analytics, Piwik has 5 slots per scope. For this reason, I have selected index 5, to allow you for 4 more indexes. </p>
<p>Place the below code INBETWEEN <code><strong> var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);</strong></code> and <code><strong>piwikTracker.trackPageView();</strong></code> in your Piwik Tracking Code</p>
<pre class="brush: php; title: ; notranslate">
 {...}
$(document).ready(checkAds());

function checkAds() {
        if ($(&quot;.adsense&quot;).height() == &quot;0&quot;) {
       document.write(&quot;&lt;script&gt;piwikTracker.setCustomVariable(5, 'Adblock', 'True', 'page'); &lt;\/sc&quot; + &quot;ript&gt;&quot;);}    
		else
		{
		document.write(&quot;&lt;script&gt;piwikTracker.setCustomVariable(5, 'Adblock', 'False', 'page');  &lt;\/sc&quot; + &quot;ript&gt;&quot;);}	
		}	
{...}
</pre>
<p>So when done, it will look like this:</p>
<pre class="brush: php; title: ; notranslate">
&lt;!-- Piwik --&gt; 
&lt;script type=&quot;text/javascript&quot;&gt;
var pkBaseURL = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://localhost/piwik/&quot; : &quot;http://localhost/piwik/&quot;);
document.write(unescape(&quot;%3Cscript src='&quot; + pkBaseURL + &quot;piwik.js' type='text/javascript'%3E%3C/script%3E&quot;));
&lt;/script&gt;&lt;script type=&quot;text/javascript&quot;&gt;
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + &quot;piwik.php&quot;, 1);

/* Adblock Check */
$(document).ready(checkAds());

function checkAds() {
        if ($(&quot;.adsense&quot;).height() == &quot;0&quot;) {
       document.write(&quot;&lt;script&gt;piwikTracker.setCustomVariable(5, 'Adblock', 'true', 'page'); &lt;\/sc&quot; + &quot;ript&gt;&quot;);}    
		else
		{
		document.write(&quot;&lt;script&gt;piwikTracker.setCustomVariable(5, 'Adblock', 'false', 'page');  &lt;\/sc&quot; + &quot;ript&gt;&quot;);}	
		}	

/* end Adblock Check */

piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
&lt;/script&gt;&lt;noscript&gt;&lt;p&gt;&lt;img src=&quot;http://localhost/piwik/piwik.php?idsite=1&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;&lt;/noscript&gt;
&lt;!-- End Piwik Tracking Code --&gt;
</pre>
<p>Once you are done you will be able to get some fun data like below:</p>
<p>Piwik<br />
<img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/02/adblock-unblock-piwik-analytics.png" alt="adblock unblock piwik analytics How Many Users Block Your Ads? Find Out!" width="619" height="275" class="aligncenter size-full wp-image-589" title="How Many Users Block Your Ads? Find Out!" /></p>
<p>Google<br />
<img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://www.statstory.com/wp-content/uploads/2013/02/adblock-unblock-google-analytics-1024x298.png" alt="adblock unblock google analytics 1024x298 How Many Users Block Your Ads? Find Out!" width="600" height="174" class="aligncenter size-large wp-image-588" title="How Many Users Block Your Ads? Find Out!" /></p>
<p>There you go&#8211; now find out how many users actually see you ads and how each type behaves on your site.</p>
<p><a href="http://www.statstory.com/how-many-users-block-your-ads-find-out/">How Many Users Block Your Ads? Find Out!</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.statstory.com/how-many-users-block-your-ads-find-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tracking Events in Google Analytics</title>
		<link>http://www.statstory.com/tracking-events-in-google-analytics/</link>
		<comments>http://www.statstory.com/tracking-events-in-google-analytics/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 01:33:06 +0000</pubDate>
		<dc:creator>Adrian Speyer</dc:creator>
				<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Event Tracking]]></category>
		<category><![CDATA[MailTo]]></category>

		<guid isPermaLink="false">http://www.statstory.com/?p=556</guid>
		<description><![CDATA[Basics of an event tracking Event tracking is one of the amazing flexible parts of Google Analytics. With Event Tracking, you can get information on the actions your users make on your site. Once you have the standard tracking for Google Analytics installed, you can use events on your page. An event call consists of [...]<p><a href="http://www.statstory.com/tracking-events-in-google-analytics/">Tracking Events in Google Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.statstory.com/wp-content/uploads/2013/02/event-tracking2.png"><img style=' float: left; padding: 4px; margin: 0 7px 2px 0;'  src="http://www.statstory.com/wp-content/uploads/2013/02/event-tracking2-300x122.png" alt="event tracking2 300x122 Tracking Events in Google Analytics" width="225" height="92" class="alignleft size-medium wp-image-557" title="Tracking Events in Google Analytics" /></a></p>
<p><strong>Basics of an event tracking</strong><br />
Event tracking is one of the amazing flexible parts of Google Analytics. With Event Tracking, you can get information on the actions your users make on your site. Once you have the standard tracking for Google Analytics installed, you can use events on your page. An event call consists of a push of data to Google Analytics, with the following parameters: category, action, label (optional), value (optional) and non-interaction parameter (optional).</p>
<p>It will look like the below: </p>
<pre class="brush: php; title: ; notranslate">
_gaq.push(['_trackEvent','category', 'action', 'label', 'value', 'noninteraction']);
</pre>
<p>In this case, once the page is loaded an event will be fired off to Google Analytics to be recorded. However, for maximum benefit, one should include a true user interaction. The most common type of interaction would be a click. In this case, the Event call would look like below:</p>
<pre class="brush: php; title: ; notranslate">
&lt;a href=&quot;#&quot; onClick=&quot;_gaq.push(['_trackEvent', 'category', 'action', 'label', 'value', 'noninteraction']);&quot;&gt;Link Here&lt;/a&gt;
</pre>
<p>What happens with the above code is a click on the link, will record data to Google Analytics. Before moving on with events, let&#8217;s look at&#8230;</p>
<p><strong>Anatomy of an Event</strong><br />
To create a successful event you need to fill some following parameters (which we listed earlier). Now let&#8217;s look at each one of them a bit closer. </p>
<p><em>category (required)</em><br />
This is the name you want to give for the collection where actions you want to track will occur. An example of category could be Video’s or Datasheets.</p>
<p><em>action (required)</em><br />
This is a string which is paired with each category, and most often is used to describe the user interaction with your content. An example could be play, click or download.</p>
<p><em>label (optional)</em><br />
This is an optional string which can be valuable in adding a dimension to the event data. Usually I use it to differentiate content. For example, if you want to know which specific video is played or which datasheet is downloaded.</p>
<p><em>value (optional</em>)<br />
This is a number, which you can use to provide a numerical dimension to a user action. Normally, I leave this blank unless I have an ecommerce reason. For example if you have a form, where a user can fill in a price or quantity, you can pass this value via an event.</p>
<p><em>non-interaction (optional)</em><br />
This is a crucial aspect which Google Analytics added to change how events and bounces are calculated. A bounce in Google’s definition here is a session containing only one interaction hit. By default (i.e leaving this blank) an event hit sent by _trackEvent() is considered an interaction hit, which means that it is included in bounce rate calculations. If you set the value to true, the type of event hit is not considered an interaction hit. An example would be a page with a video embedded. Setting this to true, means the video interaction will not be used in the Bounce Rate calculation –which in fact could raise your Bounce Rate and create a stricter interpretation of bounce rate. Default (blank) is false. More details on Non-interaction from Google <a href="http://analytics.blogspot.ca/2011/10/non-interaction-events-wait-what.html" title="non-interaction-events">here</a>. </p>
<p>Putting it together, using an example of a pdf download, would look like below</p>
<pre class="brush: php; title: ; notranslate">
_gaq.push(['_trackEvent' ,'PDF Datasheets', 'Download', 'WidgetB', 1.50, true]);
</pre>
<p>If I leave off value and noninteraction, the Event would look like below</p>
<pre class="brush: php; title: ; notranslate">
_gaq.push(['_trackEvent','PDF Datasheets', 'Download', 'WidgetB']);
</pre>
<p>There is tons more about Event Tracking, so if you need even more details, I recommend you check out the official Google documentation on <a href="https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide" title="Google Analytics Event Tracking">Event Tracking</a> </p>
<p><img style=' float: left; padding: 4px; margin: 0 7px 2px 0;'  class="alignleft size-medium wp-image-550" alt="mailto 300x300 Tracking Events in Google Analytics" src="http://www.statstory.com/wp-content/uploads/2013/02/mailto-300x300.png" width="100" height="100" title="Tracking Events in Google Analytics" /> </p>
<p><strong><a id="mailto-ga">Tracking Mailto with Events</a></strong><br />
I was asked a question by one of the readers (<a href="http://www.statstory.com/tracking-contact-form-7-with-piwik-google-analytics/#comment-792522339" title="Question About Tracking Mailto in Google Analytics">hi Martijn</a>) of this blog on how to track clicks on an mailto link. I wanted to get a bit more creative and have some fun with request. Below are the steps and the code to make this happen.</p>
<p><strong>Setup with jQuery, Tracking Code and HTML</strong><br />
The first step is to include the jQuery Library. If you are unsure if your page/website has it included just, click view source and look for the word &#8220;jquery&#8221; or &#8220;jquery.min.js&#8221;. If you do not have it, it’s easy to add. Google actually hosts a version of jQuery, so you can include it easily with the below markup in the <code>&lt;head&gt;&lt;/head&gt;</code> of your page. </p>
<pre class="brush: php; title: ; notranslate">
&lt;!-- Call to jQuery--&gt;
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;!--end of jQuery call--&gt;
</pre>
<p>Next you want to place your Google Analytics tracking, which to be in the appropriate place is just before <code>&lt;/head&gt;</code>.You will then need an Email link to track. Here is the basic HTML for that:</p>
<pre class="brush: php; title: ; notranslate">
This is an email link:&lt;a href=&quot;mailto:youremail@yourdomain.com?Subject=Test&quot;&gt;Send Mail&lt;/a&gt;
</pre>
<p><em>Please note if your subject spaces, replace them with  %20 to ensure that it would be rendered properly.</em></p>
<p><strong>Time for some magic&#8230;</strong><br />
Up to now, nothing will be tracked. Below is the code that makes mailto tracking work and sends the event to Google Analytics.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!--Track mailto--&gt;
&lt;script&gt;
jQuery(document).ready(function($) {
    $('a[href^=&quot;mailto&quot;]').click(function(){
	_gaq.push(['_trackEvent', 'email', 'send', this.href.replace(/^mailto:/i, ''),,true]);    });
});
&lt;/script&gt;
&lt;!--End Track mailto--&gt;
</pre>
<p>The above code will record the the email click and in this case, the category is email, the action is send, the label will be <code>youremail@yourdomain.com?Subject=Test</code></p>
<p>If you want only the page that the user emailed from, maybe for example, if your link test was &#8220;share this page&#8221;, the code you will need would look like something below:</p>
<pre class="brush: php; title: ; notranslate">
_gaq.push(['_trackEvent', 'email', 'shared', location.href,,true]);
</pre>
<p>If you want to have the email subject and the page location, below is how you would combine the two:</p>
<pre class="brush: php; title: ; notranslate">
_gaq.push(['_trackEvent', 'email', 'send', this.href.replace(/^mailto:/i,'') + ' /Page = ' + location.href,,true]);
</pre>
<p>Ok, so now let&#8217;s put it all together:</p>
<pre class="brush: php; title: ; notranslate">
&lt;!--Track mailto--&gt;
&lt;script&gt;
jQuery(document).ready(function($) {
    $('a[href^=&quot;mailto&quot;]').click(function(){
	//_gaq.push(['_trackEvent', 'email', 'send', this.href.replace(/^mailto:/i, ''),,true]); //will only record the email of the mail-to
	//_gaq.push(['_trackEvent', 'email', 'shared', location.href]);// will record the page mailto was shared from or clicked
	//_gaq.push(['_trackEvent', 'email', 'send', this.href.replace(/^mailto:/i,'') + ' /Page = ' + location.href,,true]);//email link &amp; page the user was on
    });
});
&lt;/script&gt;
&lt;!--End Track mailto--&gt;

&lt;!--Mailto Link--&gt;
This is an email link:&lt;a href=&quot;mailto:youremail@yourdomain.com?Subject=Test&quot;&gt;Send Mail&lt;/a&gt;
&lt;!--End Mailto Link--&gt;
</pre>
<p>This way you can decide which you want. Just remove the “//” before the _gaq.push for the one that works best for you.</p>
<p>That’s all folks. Now go have some fun with events.</p>
<p>Side note for my Piwik Friends<br />
Event tracking equivalent for Piwik is Custom Variables. You can learn about Custom Variables for Piwik <a href="http://www.statstory.com/custom-variables-in-piwik/" title="Piwik Custom Variables">here</a>. I also have a post on doing mailto click tracking for Piwik <a href="http://www.statstory.com/tracking-mail-to-clicks-with-piwik-analytics/" title="Piwik Analytics MailTo Tracking">here</a>.</p>
<p><a href="http://www.statstory.com/tracking-events-in-google-analytics/">Tracking Events in Google Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.statstory.com/tracking-events-in-google-analytics/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Tracking Mail-To Clicks with Piwik Analytics</title>
		<link>http://www.statstory.com/tracking-mail-to-clicks-with-piwik-analytics/</link>
		<comments>http://www.statstory.com/tracking-mail-to-clicks-with-piwik-analytics/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 00:54:29 +0000</pubDate>
		<dc:creator>Adrian Speyer</dc:creator>
				<category><![CDATA[Piwik]]></category>
		<category><![CDATA[custom variables]]></category>
		<category><![CDATA[MailTo]]></category>

		<guid isPermaLink="false">http://www.statstory.com/?p=549</guid>
		<description><![CDATA[Custom Variables to Record Actions Custom Variables as we have learnt are very flexible. I wanted to share another cool way you could use events: to track an action taken on your website. In this case, we are going to learn below how to use Custom Variables to track clicks for a Mailto link. As [...]<p><a href="http://www.statstory.com/tracking-mail-to-clicks-with-piwik-analytics/">Tracking Mail-To Clicks with Piwik Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></description>
				<content:encoded><![CDATA[<p><img style=' float: left; padding: 4px; margin: 0 7px 2px 0;'  class="alignleft size-medium wp-image-550" alt="mailto 300x300 Tracking Mail To Clicks with Piwik Analytics" src="http://www.statstory.com/wp-content/uploads/2013/02/mailto-300x300.png" width="150" height="150" title="Tracking Mail To Clicks with Piwik Analytics" /> </p>
<p><strong>Custom Variables to Record Actions</strong><br />
Custom Variables as <a href="http://www.statstory.com/custom-variables-in-piwik/" title="Custom Variables in Piwik Analytics">we have learnt</a> are very flexible. I wanted to share another cool way you could use events: to track an action taken on your website. In this case, we are going to learn below how to use Custom Variables to track clicks for a Mailto link. As this was <a href="http://dev.piwik.org/trac/ticket/2731" title="Mailto Tracking Disabled">disabled</a>, I figured I would add here a way to get the tracking Mailto automatically.</p>
<p><strong>Using jQuery </strong><br />
The first step to tracking a Mailto action is to include the jQuery Library. If you are unsure if your page/website has it included, just click view source and look for the word &#8220;jquery.js&#8221; or &#8220;jquery.min.js&#8221; . If you do not have it, it’s easy to add. Google actually hosts a version of jQuery, so you can include it easily with the below markup in the <code>&lt;head&gt;&lt;/head&gt;</code> of your page.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!-- Call to jQuery--&gt;
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;!--end of jQuery call--&gt;
</pre>
<p><strong>Ensure You have Piwik Tracking</strong><br />
It goes without saying oyu need Piwik installed, and you want to ensure you have placed your Piwik Analytics tracking code on your site. It should be placed just before <code>&lt;/body&gt;</code> tag on your site.</p>
<p><strong>Now for the HTML</strong></p>
<p>You need to have a mailto link to track. Here is the basic HTML for an email link</p>
<pre class="brush: php; title: ; notranslate">
This is an email link:&lt;a href=&quot;mailto:youremail@yourdomain.com?Subject=Test&quot;&gt;Send Mail&lt;/a&gt;
</pre>
<p>Please note if your subject spaces, replace them with  %20 to ensure that it would be rendered properly.</p>
<p>Now comes the magic that makes this work and sends the custom variable to your Piwik Analytics install:</p>
<pre class="brush: php; title: ; notranslate">
&lt;!--Track mailto--&gt;
&lt;script&gt;
jQuery(document).ready(function($) {
    $('a[href^=&quot;mailto&quot;]').click(function(){
	piwikTracker.setCustomVariable(1, &quot;Share By Email&quot;, location.href, &quot;page&quot;);  piwikTracker.trackPageView(); 
    });
});
&lt;/script&gt;
&lt;!--End Track mailto--&gt;
</pre>
<p>The above code will record the page from which the Mailto link was clicked. If you want the email subject, the code would look like below:</p>
<pre class="brush: php; title: ; notranslate">
{...}
piwikTracker.setCustomVariable(1, &quot;Share By Email&quot;, this.href.replace(/^mailto:/i, ''), &quot;page&quot;);  piwikTracker.trackPageView();
{...}
</pre>
<p>If you want to have the email subject and the page location, below is how you would combine the two:</p>
<pre class="brush: php; title: ; notranslate">
{...}
piwikTracker.setCustomVariable(1, &quot;Share By Email&quot;,  'Email='+this.href.replace(/^mailto:/i,'') + ' /Page = ' +  location.href, &quot;page&quot;);  piwikTracker.trackPageView();
{...}
</pre>
<p>To get the above the final code would look like this:</p>
<pre class="brush: php; title: ; notranslate">
&lt;!--Track mailto--&gt;
&lt;script&gt;
jQuery(document).ready(function($) {
    $('a[href^=&quot;mailto&quot;]').click(function(){
	piwikTracker.setCustomVariable(1, &quot;Share By Email&quot;,  'Email='+this.href.replace(/^mailto:/i,'') + ' /Page = ' +  location.href, &quot;page&quot;);  piwikTracker.trackPageView();
    });
});
&lt;/script&gt;
&lt;!--End Track mailto--&gt;
</pre>
<p>So there you have it. Now you have an easy way to track your mailto links in Piwik Analytics! </p>
<p><a href="http://www.statstory.com/tracking-mail-to-clicks-with-piwik-analytics/">Tracking Mail-To Clicks with Piwik Analytics</a> is a post from: <a href="http://www.statstory.com">StatStory</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.statstory.com/tracking-mail-to-clicks-with-piwik-analytics/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
