> For the complete documentation index, see [llms.txt](https://resource.haunv.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://resource.haunv.com/content/analytics/google-analytics.md).

# Google Analytics

Có hai cách để chúng ta tạo tài khoản Google Analytics và gắn lên website. Một là gắn code trực tiếp lên website và thứ hai là dùng trung gian Google tag Manager.

Trong bài này chúng ta tìm hiểu cách dùng Google Analytics gắn code trực tiếp lên website.

### Bước 1: Đăng ký tài khoản Google Analytics

![Google Analytics home page](/files/-MOzRmLKUZ-r16Gut-UK)

* Chúng ta vào trang <https://analytics.google.com/analytics/web/provision>
* Click Start để tạo tài khoản

![Tên tài khoản](/files/-MOzSB2o1UzM9hXEZHVz)

* Chúng ta thêm tên tài khoản cần tạo - bạn có thể đặt theo tên website
* Kéo xuống click next để tiếp tục

![Điền tên property - đặt theo tên website cũng được](/files/-MOzSezvPsgpE_J2DLO7)

* Điền đầy đủ tên dự án và vị trí, tiền tệ
* Sau click next để tiếp tục

![Chọn danh mục quy mô doanh nghiệp](/files/-MOzTDPA8w1KGep99d8P)

* Click chọn danh mục ngành của website
* Chọn quy mô doanh nghiệp
* Chọn tick toàn bộ những gì cần tối ưu
* Click "Creat" để tiếp tục

![Accept đồng ý thể lệ Google](/files/-MOzT_avQf4a88wZ5K3K)

* Tick chọn đồng ý thể lệ của google
* Click "i accept" để tạo tài khoản

![Gửi email cho bạn](/files/-MOzTqzlFe20i0zP7KGS)

* Click vào website để tiếp tục

![Web](/files/-MOzU0x4_9KAY3BbOlxy)

* Tiếp tục thêm website để cài đặt&#x20;
* Như vậy là hoàn thành phần khai báo

![set up website](/files/-MOzUNeJZFfWgbuno_Tp)

* Copy mã code theo dõi&#x20;

![Mã theo dõi](/files/-MOzUaFRAloJV60qirbZ)

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

  gtag('config', 'G-KF534W1JP0');
</script>
```

### Bước 2: Đưa mã code theo dõi vào website

* Chúng ta đưa code vào thẻ \<head> ... \</head> của website và tải lên hosting để hoàn thành cài đặt.

![code trong thẻ head](/files/-MOzV7wqTNhvfn_G16CB)

### Bước 3: Vào trang Google Analytics để xem báo cáo

* Chúng ta vào trang <https://analytics.google.com/analytics/web/> để xem báo cáo

![Thống kê trong GA](/files/-MOzWToHyB46gIVQP1IY)

Như vậy chúng ta đã tìm hiểu xong cách cài đặt và xem dữ liệu từ Google Analytics.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://resource.haunv.com/content/analytics/google-analytics.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
