Google Analytics on Hexo

I’ve implemented Google Analytics to my blog :)

I have always been interested in user(audience) analysis, and wanted to implement Google Analytics to my personal website. So I did!

Here’s brief review of what I did.

  1. Create GA account
    This is super simple. Just visit Google Analytics website and sign up, following the directions.

  2. Get your tracking code
    CMS’ like wordpress have Google Analytics plugins prepared, but custom pages don’t. So we need to implement GA code into our websites.

Click Admin tab on your left sidebar, which is the second from bottom icon. Click Tracking Info-Tracking Code from the middle column.

You’ll then see Global Site Tag code. Copy and paste this code to your <HEAD> part of website as first element!

I’ve struggled a bit because I didn’t put it as my first element.

I guess the order does matter due to other scripts and things, so please make sure it’s the first.

You should soon see data collections happening :)

You can modify this by separating Tracking ID to your theme’s _config.yml file, or implement multiple analytics in your website but I’ll just cover this much for now.

Share