Tackling Google Analytics in Kentico 11

By Pavel Jirik in Kentico
·5 min read

Welcome to 2018! Are you still sticking to your New Year's resolution you came up with at the very end of 2017? I bet you are, as it is just the fourth day, and your motivation levels should be high! What about business goals? Are you ready to surpass your company's last year’s numbers, and reach another level? Perfect! Just make sure you measure your success, otherwise, you might go off track.

As with every goal setting, you need to know exactly what it is that you are trying to achieve. In the case of a website, you have to be clear about your online stats such as page views, landing pages, exit pages, bounce rate, and so on. But there are also some other metrics that you may be interested in. For example, an insight into how much your customers spent last month, or which of your products is being sold the most.

Measuring, measuring, and measuring—that is the key to a successful strategy! If you don't measure your overall online statistics, then it will be difficult for you to identify weak spots that could (and should) be improved.

Will you achieve 1,000 downloads of your eBook within the next month? Or rather 2,000 downloads? How would you set such a goal without knowing how your current eBook downloads were doing? It would just be some number from the top of your head, not relevant to the reality happening on your website.

On the other hand, if you consistently kept track of your website statistics, you would be able to see the real numbers of your eBook downloads, and be able to create a much more informed action plan to improve the download numbers.

This applies to anything happening on your website. When it is not measured, then it is invisible (and doesn't exist) in the marketing and business world.

Thankfully, there are many approaches in Kentico 11 that can be used to measure all that is necessary to set your next goal(s) just right.

For example, you could enable Kentico 11's native Web Analytics feature, which would allow you to track various statistics on your website out of the box without the need to connect a third-party tool.

On the other hand, if you are a well-rounded digital marketer accustomed to the Google Analytics interface, you might be willing to stick to it instead. And guess what? We have got you covered as well. You can easily set up Google Analytics tracking in Kentico 11 by using its native web parts (or widgets), and even track e-commerce statistics with ease.

Google Analytics Web Part

If you want to track just common website statistics (page views, bounce rates, exit pages, etc.), you can just use this web part right away. Simply select the top (root) master page in the Pages app in Kentico 11, and place the Google Analytics web part anywhere on that page. Every page inheriting from the master page will automatically contain the web part as well. Then, just put (copy-paste) your Google Analytics Tracking ID from the GA interface into the web part's Tracking code property:

By default, the web part is set to track only the main domain of your website (e.g., only www.example.com).

However, you can also set it to track even the subdomains of the domain (e.g., sub1.example.com, sub2.example.com, sub3.example.com), or only the top-level domains (www.example.com, www.example.net, www.example.org, etc.).

So, depending on your needs, select the option that applies to you the best, and save the web part's settings.

Well done! You are now tracking Google Analytics statistics for every page of your website that inherits the master page. You don't have to worry about the placement of the GA tracking code on your website anymore as the web part does it for you automatically.

Javascript Web Part

Another option is to use Kentico 11's Javascript web part. It is a more flexible web part that gives you complete freedom over the format of the tracking code placed on the page. It needs to be placed on the master page as well so that inheriting pages will contain the web part.

You could copy the tracking code snippet from the Google Analytics interface and paste it into the web part's In-line script property:

If the tracking snippet already contains <script> tags, you just need to uncheck the Generate script tags checkbox (so that Kentico 11 does not add the extra script tags), and you can save the web part. Perfect! You are now tracking Google Analytics statistics! Different approach, but the same result.

Adding Google Tag Manager Code

But there is more to it. As you have greater flexibility over the tracking code with the Javascript web part, you can use it to place a Google Tag Manager tracking code snippet on the web page as well. The only thing to remember is that the tracking code has two parts. Therefore, you will need to use two Javascript web parts instead of just one.

The first part of the code needs to be placed in the <head> part of the website, which is fine in this case, as the web part does it for you automatically. So, no big deal there.

However, the second part of the code needs to be placed at the beginning of the <body> part of the page. This is the moment you need to place a second Javascript web part on the master page, paste the second part of the Google Tag Manager tracking code into its In-line script property, and choose the Beginning of the page option (this instructs Kentico 11 to place the code right after the <body> tag) from the In-line script page location drop-down list:

Then, just make sure the Generate script tags checkbox is unchecked (so that no extra <script> tags are generated), and save the second Javascript web part.

And you are done. Now, you can return to the Google Tag Manager interface, and set up the website tracking from there with ease!

Tracking E-commerce Analytics

When you use Google Analytics for website tracking, it would be quite a shame not to track e-commerce statistics as well. This is something that we tried to make as easy as possible for you in Kentico 11. You can take an advantage of three system macros that return all necessary details in the right format to Google Analytics. This is a slightly more advanced topic that is greatly explained in our documentation. So, if you want to start tracking your e-commerce statistics as soon as possible, then dive right into it!

Are you using Kentico's Web Analytics and Google Analytics alongside each other, or do you just prefer to use one of them instead? Let us know in the comments!

By Pavel Jirik in Kentico
search
Forrester report
We're named a Strong Performer in the Q4 2018
Forrester Wave™ for WCM!
×