Month: March 2017

Recently I thought it would be great to know how many users (if any) are visting my blog, main website and other sites on my domain. With that in mind I decided to add some google analytics to my sites in order to simply track the number of users (at least that’s what I want to do for now; google analytics is much more powerful than that, but I have yet to explore those capabilities).

I created a google analytics account (which you can do here) and went through the basic setup. I finally created a properties for my blog and my main website. My main website being the one found here: https://newteq.co.za. Both sites have different tracking codes as I would like to monitor traffic on my main website and my blog site separately.

In order to track activity on the sites, a different approach is required for each, since my blog is a wordpress site and my main website is simply a static HTML website. I proceeded to add the tracking code snippet (information on how to do that can be found here) and then tried to test it out. It wasn’t working… I thought let me give it a day or so and try again, in the meantime, I’ll set up the tracking on the blog site too.

For my blog’s tracking, I installed this plugin by MonsterInsights. It’s a great plugin that lets you authorize the WordPress site to use your google analytics account, and then you can provide the actual tracking ID that needs to be used for tracking. After setting up the MonsterInsigths plugin, I provided the tracking ID and yet again, I was unable to view my traffic on the site. Again, I thought let me just give it a day and check back.

The next day came and I was still having problems. I then found this Tag Assistant chrome extenstion here. And once everything was set up with this extension, I found that I was getting an error. The error read: Missing HTTP Response. After searching around for a while, I came across this page here. On this page, the guy said that he found out that google analytics was being blocked by an Ad Blocker. So I did a little more digging and found this site: Which Ad Blockers are blocking Google Analytics.

A couple of months ago, I moved from AdBlock Plus to uBlock Origin. And from the table given in the above mentioned website, I could see that uBlock was blocking google analytics. I went over to my website, disabled uBlock on my website, and BAM. Traffic was now being recorded.

Now, there are ethical and moral debates that can be had about using Ad Blockers but this isn’t the forum for that. There are similar debates that can be made about tracking users who don’t want to be tracked. For this reason, I would like to implement the following approach on my sites; an article written by the same guy that gave us the wonderful ad blocking table also wrote this: How to track if Google Analytics is blocked – in Analytics! In this article he basically describes that all he wants to do is track the number of users which are actually blocking Google Analytics, and nothing more. Is approach is perfect for my purposes as I simply want to understand how much traffic (visitors) my sites are getting on a daily basis.

In Philip’s article mentioned above, he using JS and PHP to implement the tracking (of users that have blocked Google Analytics). This approach should be straight forward for me to implement on my main website, but I’m going to have to investigate how this can be done on the WordPress (my blog) site.

I’ll post an update on how this can be achieve in WordPress once I have figured it out 🙂

Update 1:

Turns out that, uBlock Origin does not block the ga object from being created. When this code is run:

JavaScript

1

2

3

4

5

6

7

8

9

10

11

window.addEventListener('load',function(){

if(window.ga&&ga.create){

console.log('GA loaded.');

}

else{

varimg=document.createElement('img');

img.setAttribute('style','width:0px;height:0px;display:none;');

img.src='/ping.php';

document.body.appendChild(img);

}

},false);

The console outputs GA loaded. so, the php code will never be run. After I inspected the network tab in the developer options, I found this (click on the small image to expand it):

As you can see, the call to the analytics API is what is actually blocked by uBlock Origin. This would explain the initial “Missing HTTP Response” error that I was getting, since uBlock Origin, stopped the request after it was sent out.

I will need to find another way to implement this.

If anyone has any suggestions, please let me know in the comments.

Update 2:

While searching the web, I manage to come across two approaches to determining if a user has an ad blocker installed. One here and another here. The first approach does not seem to work for uBlock Origin, as I was not getting the desired results. The second approach using a custom ads.js file, worked like a charm :)…

Further, the only problem with this method is that requests sent to google analytics are still intercepted and blocked by uBlock Origin. This means that I am currently still unable to track users if uBlock Origin is installed.

The purpose of this post is for me to announce the availability of a new “site” on my domain – a wiki site. This site can be found at: https://wiki.newteq.co.za.

I will be using the wiki site for more tutorial based posts and things to keep in mind when setting up servers, or configurations for applications.

My first post on the wiki platform will be an item regarding the set up of SSL on your apache web server, using Let’s Encrypt . Let’s Encrypt is a great way to get your website SSL secured without having to pay for SSL certs. The Let’s Encrypt drive is to ensure that all web traffic is sent over HTTPS. Let’s Encrypt ensures that you own the server that you are wanting to enable SSL on, making it perfect for anyone (like myself) who would like to ensure that their content is served over HTTPS, but aren’t a huge corporate with big pockets to get the Verisign (or similar) certs.

I have only covered a very high level overview of my understanding of Let’s Encrypt. If you wish to find out more about it, please visit their website

Once I have completed the Let’s Encrypt tutorial, I will be posting another article on here as notification.