There are a few ways khổng lồ add Google Analytics tracking code khổng lồ your trang web. Adding Google Analytics to lớn your trang web enables you to traông xã the number of visitors to your site, the search keywords they use lớn find your site, the time spent on your site, goal conversion & much more.

Bạn đang xem: Google analytics

A few housekeeping items before we move forward, this tutorial assumes that you already have sầu a Standard Google Analytics tài khoản & not a Google Analytics 360 trương mục. Second, that you have already phối up a property in Google Analytics, which allows you to lớn generate a tracking ID (more on this later).

With that settled, we’ll explore two ways to add Google Analytics code khổng lồ your trang web.

Google Analytics Tracking Code

The first step you’ll need lớn vị is find your tracking ID, which is a chất lượng ID created for your Google Analytics account.

To get your tracking ID, follow these steps:

Log in to your Google Analytics tài khoản On the bottom left-hand side of the page, click Admin From the left column titled Account, select an trương mục from the dropdown thực đơn From the middle column titled Property, select a property from the dropdown thực đơn Under the Property column, cliông chồng Tracking Info > Tracking Code Your website’s chất lượng tracking ID is shown at the top of the page under Tracking ID & starts with UA

Once you’ve sầu identified your tracking ID, you’ll need lớn get your tracking code snippet, which can be found on this page as the Global Site Tag (gtag.js). The gtag.js is the tracking code for this specific property & you’ll need khổng lồ copy and paste this code lớn every webpage you want khổng lồ track on your trang web.

Xem thêm: Page Not Found - Mcdonald'S Consumer Insights

To copy và paste your gtag.js, follow these steps:

Copy the gtag.js shown on the page (example shown below)


Replace the GA_TRACKING_ID with your unique tracking ID provided by Google Analytics Paste the code snippet right after the tag on each page of your site that you’d like to lớn traông chồng in Google Analytics

Keep in mind that gtag.js (launched in 2017) is a newer, more expanded version of analytics.js.

Google Tag Manager

You can also use Google Tag Manager to add the Google Analytics code lớn your trang web. Google Tag Manager is a free tool và is useful for websites that use multiple analytics or advertising performance tools from multiple campaigns.

To install Google Analytics code via Google Tag Manager (GTM), follow these steps:

(Source: Google Analytics Documentation)

In GTM, select Create Tag & choose Google Analytics Then select Universal Analytics Name your tag, preferably something related to Google Analytics (lượt thích GA). Add your Google Analytics property ID or gaProperty variable. Choose the Track Type (i.e. Page View) Choose your firing triggers such as All Pages, which the tag will fire the tracker on every page of your website

Gtag.js or Google Tag Manager?

If your trang web is already using Google Tag Manager, then gtag.js is not necessary and continue khổng lồ use GTM. Since GTM inherently combines sự kiện data from Google Analytics & Google Adwords, it’s best khổng lồ keep it running if it’s already in place.

However, if you haven’t installed GTM và are not planning on investing in Google Adwords, using the gtag.js may be beneficial lớn your trang web. The gtag.js tag makes the tracking process easier by:

Streamlining the installation process khổng lồ get Google Analytics code on your site faster Allowing you to skết thúc event data to lớn multiple tools as once Keeping all tracking tags in once place in your trang web code

Either way, we recommover that you add Google Analytics to lớn your website, so you can keep traông xã of all your sự kiện data.