Adding Google Analytics to Jekyll and Github Pages sites
Introduction
In today’s Internet SEO is one of the most important part of every organization. It can be a deciding factor on what customers are choosing. Today nobody goes to 2nd page in google search results. And there are billions of results for every search query.
So to be not lost in the wild, Search Engine Optimization is used which particulary gives your website a boost. It generally has some bunch of features and norms that must be satisfied and implemented to adhere to standards.
Second important feature is knowing your visitors, your visitor’s age group, preferences, habits and much more. For that also there are a bunch of tools available. **Google Analytics is one of them.
Integrating Google Analytics to Jekyll sites hosted on Github pages
- Sign up for google analytics.
- Get your tracking code from your dashboard
- Since I am using Minimal-Mistakes theme, i have to put the script inside `_include/analytics-providers/google-universal.html
- Otherwise create a new file
_include/analytics.html
and put your tracking code there. Jekyll will automatically copy your tracking code to every web page. - After this add changes to
_config.yml
analytics sectionanalytics: provider: "google-universal" google: tracking_id: "UA-1234567-8"
Google Analytics is done. :D
Verifying property
Next step is to verify your site property ownership-
- The recommended method does work, just download file put it in your github repository and you are good to go. (Don’t put www as your top level domain in google property)
- Also the meta tag verification in alternate methods in google webmaster tools works.
- Add a custom variable in
config.yml
and then add it to_layouts/default.html
as a meta tag. This will verify your ownership to the site. Reference - Link
Adding sitemap.xml
- Add your sitemap.xml to google webmaster dashboard for crawler to efficently crawl your website.
- BTW it will by default use your sitemap.xml for crawling and also robots.txt
- Take the Google Mobile Friendly test and upload the results.
Leave a comment