If you're building and managing an eye-catching, unique website for your business, the next step is to monetize, right? But before you start earning, it's crucial to ensure that your website attracts the necessary traffic. This is where Google Analytics comes in. By embedding the Analytics code into your website or app, you can track page traffic, ensuring that your visitors are having a great experience.
Steps
Create an Account

Go to the Google Analytics website. Navigate to google.com/analytics/ in your browser. Click the 'Access Analytics' button in the upper right corner. This will take you to a new page showing an overview of how Analytics works. Click on 'Sign up' to create your Analytics account.
- You will need to sign in with your Google account.
- If you prefer to separate your Analytics data from your personal Google account, you can create a new Google account specifically for tracking Analytics data.

Choose between "Website" and "Mobile app". Use the button at the top of the page to toggle between tracking a website and tracking a mobile app.

Enter your account information. To create an Analytics account, you'll need to provide some basic details to Google. This information helps determine how Analytics data is translated and delivered to you.
- Provide your account name. This is the account that manages multiple properties you track. You can monitor up to 25 properties per account and create 100 accounts per Google account.
- Enter your website name and URL or the app's name in the “Setting up your property” section.
- Select the technology that best suits your website, and choose the time zone you'd like to use.

Choose data sharing options. There are four data sharing options you can enable or disable. These allow you to share your Analytics data with other Google programs like AdSense, anonymize data for statistical purposes with Google, and share with account experts for troubleshooting and optimizing your Analytics account.

Create an account. You'll be directed to the Admin page where you'll see the Tracking ID for your website or mobile app.

Access the Google Tag Manager page. This new tool from Google allows you to implement and modify analytics tags more quickly on your website and mobile app. Tag Manager is completely free, and you can sign up using your Google account at google.com/tagmanager/.

Create an account and add a container. The container is where you store the tags you want for your website, including Analytics, AdWords, and third-party tags. It's recommended to name the container after your website URL or app name.
- Select the type of container you need (Web, iOS, Android). Click the "Create" button.
- Click here if you want to insert tags into the website.
- Click here if you want to insert tags into the mobile app.
Insert tags into the Website

Copy the tag displayed when creating the container. This tag must be inserted into the pages you want to track.

Open the source code of each webpage. If you cannot access the page code, contact the web developer. You need to be able to edit the code to insert the tag.

Paste the copied code into the tag. Upload the updated file and repeat this process for each page. This will trigger Tag Manager to insert the tag you want on each webpage.

Click on "Add a new tag" in the container configuration page. You'll see this page after closing the window displaying the Google Tags code snippet.

Select "Google Analytics" from the Product list. Choose "Universal Analytics" and click "Continue" to proceed.

Copy and paste the Tracking ID from the Google Analytics Admin page. Choose the tracking type you want from the dropdown menu.
- Page View is the most common and simplest tracking type when someone visits your website. You can also select from various types such as events, transactions, social media clicks, etc.

Select the trigger for the tag. For the Page View tag, choose "All Pages." If there are certain pages you don't want to track, you can select "Some Pages" instead. You can also select more specific triggers from different pages.

Save the tag. Review your tag settings and click the "Save Tag" button. The new tag will appear in the list.

Publish the new tag. Click the "Publish" button, then review the displayed information. Click "Publish Now" to send the tag to the website and activate it.

Track the results. After about 24 hours, you will start receiving analytics reports. Click here for more details on how to read the reports.
Insert the Tag into the Mobile App

Set up the development tools. To activate Google Tag Manager on an Android app, you need to integrate it into the app’s source code. If you don't have access to the app code, consult with the app developer. You will need the following tools to insert the code into the app:
- Android SDK
- Google Play Services SDK
- If you wish to apply the tag to an iOS app, click here for detailed instructions.

Add permissions to the AndroidManifest.xml file. Open the file and insert the following code snippet in the permissions section:
<!-- For TagManager SDK --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Return to the Google Tag Manager page. Click on "Add a new tag" in the container's management page.

Select "Google Analytics" from the Product list. Choose "Universal Analytics" and then click on "Continue".

Copy and paste the Tracking ID from the Google Analytics Admin page. Choose the tracking type you want from the menu.
- App View is the simplest option, which notifies you whenever someone opens your app.

Save the tag and publish. This action allows you to download the container binary to integrate it into the app.

Click on the Versions tab at the top of the Tag Manager page. You will see a list of the tag versions.
Nhấp chuột vào nút "Actions" (Hành động) ngay cạnh phiên bản đầu tiên và chọn "Download" (Tải về) để tải một tập tin nhỏ về máy tính.

Tạo thư mục tài nguyên trong dự án. Đường dẫn là <project-root>/res/raw. Đổi tên tập tin tải về để loại bỏ ký tự in hoa, sau đó sao chép vào thư mục /raw/.

Tạo tầng lớp công chúng mới để mở rộng Object (Đối tượng). Đây là nơi bạn áp dụng mã Google Tab Manager.

Nhấp mã Google Tab Manager. Nhập đoạn mã dưới đây để áp dụng thẻ. Thay thế containerId bằng ID trong thùng chứa, và container_file bằng tên tập tin nhị phân thùng chứa:
TagManager tagManager = TagManager.getInstance(this); PendingResult<ContainerHolder> pending = tagManager.loadContainerPreferNonDefault(containerId, R.raw.container_file); pending.setResultCallback(new ResultCallback<ContainerHolder>() { @Override public void onResult(ContainerHolder containerHolder) { ContainerHolderSingleton.setContainerHolder(containerHolder); Container container = containerHolder.getContainer(); if (!containerHolder.getStatus().isSuccess()) { Log.e("AppName", "failure loading container"); displayErrorToUser(R.string.load_error); return; } ContainerHolderSingleton.setContainerHolder(containerHolder); ContainerLoadedCallback.registerCallbacksForContainer(container); containerHolder.setContainerAvailableListener(new ContainerLoadedCallback()); startMainActivity(); } }, 2, TimeUnit.SECONDS);

Xuất bản ứng dụng đã cập nhật. Thay đổi phía trên sẽ được báo cáo ngay khi có người thực hiện hành động trong ứng dụng của bạn. Bởi vì thẻ được thiết lập để thông báo bất kỳ sự kiện nào, bạn không cần thêm mã để kích hoạt thẻ. Nếu muốn thẻ chỉ thông báo sự kiện cụ thể, bạn cần thêm mã đặc biệt.
- Nhấp chuột vào đây để biết hướng dẫn chi tiết áp dụng Google Tags.

Start tracking results. After about 24 hours, you will begin receiving analytical reports. You can view the analysis data from your Google Analytics page. Refer to the next section for details on how to interpret the reports.
Track Results

Go to the Reporting section on Google Analytics. This will load the "Overview" page under the Behavior category, displaying basic information like the number of visits. You can see metrics such as the time visitors spend on the site, percentage increase, and decrease.

Access the Dashboard. You can view the Dashboard for each page you are tracking by using the Dashboards menu on the left side of the site. Dashboards allow you to see specific details about site traffic.

Customize the Dashboard. Each Dashboard typically comes pre-configured with basic tools. You can adjust them to better fit the needs of your site and business. Click on “+Add Widget” in the Dashboard menu to add a widget. You can also remove widgets that have been activated.

Create more Dashboards. You can add new Dashboards to monitor specific aspects of your site, with a limit of up to 20 Dashboards. To create a new Dashboard, click on the Dashboard menu and select “+New Dashboard” (+New Dashboard).
- The Startup Dashboard includes all basic tools.
- Blank Canvas contains no tools.

Use Filters to limit the displayed traffic. If you have a large number of visitors from workers, you can use Filters to hide certain traffic or display it in a specific subfolder, or even hide the traffic of that subfolder.
Set a Goal

Return to the "Admin" section of your website. Choose the account where you want to set the goal in the "Views" tab. If you have multiple websites associated with the account, you'll see a list of account names in this section.

Click on the Goals button in the left menu. Select “Create a Goal” to begin defining a new goal, and give the goal a name.
- Ensure the “Active” checkbox is selected so the goal starts tracking immediately.

Select the type of goal you wish to create. There are several templates available based on the technology you choose when setting up the Tracking Code for your website.
- Choose 'Destination' as a goal if you want to track visits to a specific URL.
- Choose 'Pages per Visit' or 'Screens per Visit' to specify the number of pages or screens a user visits. Set a 'Condition' and the number of pages to be visited. This is often referred to as 'Readers'.
- Select 'Duration' to track visit duration. Choose to measure in minutes or seconds, then input your target value. You can label these visitors as 'Frequent Users'.
- Pick 'Event' as a goal to track actions like purchasing tickets or submitting an RSVP. You'll need to come back and fill in this goal after activating Analytics Goal Tracking.
- Select 'Sales' or other e-commerce goals to monitor the number of buyers or products they choose to purchase.

Save your new goal. Press 'Save' once you have filled in all the details for your goal. You can create up to 20 goals.

Review the Goal Flow report. This report gives you insights into how visitors approach your goal. You can find the report in Standard Reporting > Conversions/Outcomes > Goals.
- It shows where visitors enter, where they go after leaving, where repeat visits occur, and more.
Enable Enhanced Analytics Features

Track email, social media, and other marketing campaigns with Google Analytics. Create custom tracking URLs for each new campaign.
- Visit the Campaigns URL Builder to create a URL for your website, source, medium, terms, name, and content. Use this custom URL in online links, and Google will track user information.
- Go to the 'Campaigns' tab. Choose 'Traffic Sources' and go to 'Sources' to analyze a specific campaign.

Set up an account linked to Google AdWords. If you have a Pay Per Click (PPC) account, link it to Analytics in order to track conversion rates and run reports for each PPC advertisement.

Utilize Event Tracking. Similar to custom URLs for campaigns, customize event links to monitor sources and track conversions, like ticket purchases.
- Include specific event details in the second half of the URL in the following order: event, category, action, and label. Refer to the "Event Tracking Guide" for more information on how to set up lightweight technical URLs. Check the "Reports" section to track event movement.
