blog

How to add Google Analytics to WordPress blog in the right way

I just found out, that Google Analytics was not counting my blog post pages. Only index page and all other subpages, but not post pages. This pages, which I am linking e.g. on twitter every time I blog!

From some time I was wondering if really only ~10 people are reading my blog. My last post about Getting started with iOS, was visited by 12 people in the day it was published and 10 in the day after.

iOS post stats

Then, on Google Analytics, I went to behavior > ‘site content’ > ‘all pages’ to check how many people visited the blog post page. And…there are no post pages in the statistics at all!

iOS post stats: pages

I knew that it is impossible, because at least I visited the post page. Then I checked statistics on Azure:

iOS post stats: Azure

There are no unique views, but even page views on Google Analytics shows less than 20 per day. I published the post around 11 am, and announced it on twitter 11:18am. Then I got 7030 requests between 12pm and 1pm. It makes sense. Of course 1 Azure request < 1 unique page view. According to Azure Management portal I had 62226 request in last week. How many unique pages views it is? I don’t know and I will never know. But I am sure it is more than 54!

Why Google Analytics didn’t track my posts? I put Google Analytics script in index.php file, in my WordPress theme directory. Apparently I forgot to check if it works for all pages.

Now, I installed Insert Headers and Footers plugin to insert script from Google. As recommended in How to Install Google Analytics in WordPress for Beginners. It seems to be working fine now. Here are statistics from today:

iOS post stats: after Google Analytics script fix

There are also other plugins like Google Analytics for WordPress or Google Analyticator, but they insert Google Analytics snippet based on communication with Google api. It means, that if Google change their API for Google Analytics, plugin may not work. I don’t want to be depend on that and just want to paste customized JS code I obtained from Google.

I also added Azure analytics script. Now, I will be able to cross-check the statistics.


First year of blogging – summary

1st year stats

Today is my small anniversary: in May 31, 2013 I wrote my first blog post. Since that day I wrote 54 blog posts (this is 55th), which is 1 post per week in average. According to Google Analytics, my blog was visited by 810 users. Is it good?

When I started blogging, this blog was hosted by Webio.pl. Now, it is on Azure. My primary domain is jj09.net. I have also two alternative domains:

This blog helps me to summarize stuff I am working on. Additionally, it helps me to improve my writing. I think I am less anonymous in Passionate Programmers World now. Occasionally I am finding my blog listed on some websites. My post about Multithreading in C# and Java was listed on Geek Reading.

I do not have any specific plans for the second year. I am graduating from Kansas State University in August and I am about to start a new job in September. This, along with moving to a different city will be the biggest challenge in this year.


New domains

Today I bought two, new domains for my blog: jedryszek.com and jakubjedryszek.com.

jedryszek.com jakubjedryszek.com

I purchased them on GoDaddy. The price was reasonable ($12.99 per domain for first year, $14.99 for renewal). GoDaddy is quite popular service. Thus I will get many online resources and support from the community.

Are you looking for domain name register? Check Five Best Domain Name Registrars.


Moving WordPress blog to Azure from Webio hosting

Microsoft Azure

I decided to move my blog from hosting on Webio.pl to Microsoft Azure (formerly Windows Azure before March, 25th 2014). Why? To get more familiar with the Cloud and especially Azure.

I did my migration following Dave Bost’s series Moving a WordPress Blog to Windows Azure:

However, not everything went smoothly and easy. Additionally, I adjusted some steps to my needs/settings/plugins/hosting(Webio).

Small adjustments

Instead of connecting through FTP to copy content (uploads/themes/plugins), I used UpdraftPlus plugin. Moreover, I am using it for weekly backups all the time. It is really nice, especially the cloud backup option, which allows me to put backup files into my Dropbox automatically.

To export my database I used phpMyAdmin provided by Webio. As Portable phpMyAdmin plugin is no longer available, I took advantage of Adminer plugin to import database on Azure. Another option is to install phpMyAdmin on Azure.

I am using iTheme2 template, which allows to export customized settings (iTheme2/import tab). After migration, you can easily import it going to the same place.

I had bunch of themes installed. I was testing/experimenting with them when I started my blog. It took me a while to find a way to remove installed theme. You need to go to Appearance/Themes, click on theme you want to remove and then click delete button in right, bottom corner. I deleted all themes, but my current one (iTheme2) and Twenty-* themes.

WordPress - Delete theme

Webio specific

Specific for any hosting provider is setting the custom domain. In order to do that on Webio, you need to go to Domains/Edit DNS entries (in polish: Domeny/Edytuj wpisy w strefie DNS tej domeny). In the image below, there are DNS entries for my domain. Only highlighted entries matters for redirecting domain to Azure:

Webio DNS settings

When you add domain entries in Azure you need to add www.* entry separately (in my case: jj09.net and www.jj09.net). More details can be found here.

Azure - manage custom domains

Remember to create/update web.config file, in order to make your custom domain and permalinks (if you use them) working correctly (as mentioned in part 5 of Dave Bost’s tutorial):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<system.webServer>
		<rewrite>
			<rules>
				<rule name="Main Rule" stopProcessing="true">
					<match url=".*"/>
					<conditions logicalGrouping="MatchAll">
						<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
					</conditions>
					<action type="Rewrite" url="index.php"/>
				</rule>
			</rules>
		</rewrite>
	</system.webServer>
</configuration>

Issues

When I was trying to set SMTP server to my gmail I received following email from Google, after try to send test email:

Google hijack warning

After following steps in provided link, the issue was fixed. There is one interesting thing: I set region for my website to WestUS. However, Google says: “Location: Spain”. Hmm…

Another issue I had was getting 404 error on .woff file (Crayon Syntax Highlighter plugin font file). I solved it, by modifying web.config file as described here.

I had also problem with Tweet, Like, Google +1 and Share plugin. It dosn’t display buttons on home page. I tried some tricks (deactivate, re-install) to solve it, but I didn’t succeed.

Pricing

For hosting on Webio.pl I was paying around $20/year (start plan). On Azure, I will need to pay at least $10/month for shared instance (required to have domain jj09.net), which is $120/year. 6x more expensive! Am I crazy? No. As I stated at the beginning, I want to play with Azure. When I decide I am done with that, I can always go back to Webio.pl or some other hosting.

After one week, my estimated bill is  2,07 €.


Micro-blog on tumblr

I created account on micro-blogging platform tumblr.

My micro-blog can be found here: jakubjedryszek.tumblr.com.

tumblr was refereed to me by Rob Connery and Scott Hanselman.

I will be using it for things, which are too long for Twitter and too short for this blog.

Moreover, tumblr seems to be good platform to start your first blog. Very fast and easy setup, nice integration with social websites (facebook, twitter etc.) and powerful customization.