Track who visited your website using Shiny and the Google Analytics API

When I made this blog I was obviously curious to know who would visit it. With Google Analytics you can add “tracking code” to your website which answers just that and much more. The code not only tells how many people visited but also shows:

  • The country and city of everybody who visited the website.
  • Which pages where visited and for how long
  • A profile of the users age, gender and interests
  • If they visited your website before or are new
  • If they came to your website through social media such as LinkedIn or Facebook
  • If they are using a desktop or mobile device and at what screen resolution

Almost every website on the internet is using some sort of “tracking code” and it can be scary to think about how much details you are giving away by just visiting a website.

To give a demonstration I made an application using R and Shiny that uses the “tracking code” to show the geographical locations of everybody that visited my website. Can you see your own location on the map? You can change the time frame using the date input.