[RUBY] Analyze your site using Google Analytics-Chapter 1

background </ font>

I decided to introduce Google Analytics because I wanted to investigate the background and the number of accesses to see if the site I am currently deploying is being viewed by users other than myself (I feel like biting a bit ... lol) Until now, I have been checking the access of my portfolio site from git traffic etc., but I would like to investigate various trends using analytics.

  • About an hour has passed since this article was set up for analytics. I haven't seen the analysis results yet, but I'd like to wait a little longer and report the situation (it will take up to 24 hours). Display results, correction information of procedures, etc. will be posted.

environment </ font>

item Contents
OS.Amazon Linux AMI release 2018.03
Ruby On Rails v5.2.4.3
MySQL v5.6

Setting procedure </ font>

Working time: 15 minutes (1) Creating a Google account (omitted) (2) Create a Google Analytics account According to the site, mainly just enter the following: ·account name ・ Website name ・ Website URL ・ Report time zone

(3) Install a tracking code When you create the above account, you will receive a tracking code. Include this in the

tag on each page of your site. In my case, it runs on rails, so I set it to application.html.erb. It will be as follows.

erb:app/views/layouts/application.html.erb


<html>
  <head>
   ...

    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxx-1"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());

        gtag('config', 'UA-xxxxxxxx-1');
    </script>

  </head>

  <body>
    <%= yield %>
  </body>
</html>

that's all.

Reference </ font>

Setting and installation method when introducing Google Analytics [for beginners] [I can't ask you anymore] What is Google Analytics? Understand from installation procedure to usage in 5 minutes!