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.
item | Contents |
---|---|
OS.Amazon Linux AMI | release 2018.03 |
Ruby On Rails | v5.2.4.3 |
MySQL | v5.6 |
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
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.
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!