Wordpress

如何在WordPress 上安裝google Analytics (GA)?

2023-02-19 最後更新:2026-02-20) · 2 分鐘 · Ray Lee (System Analyst)
  1. 登錄 Google Analytics,創建一個新帳戶或使用現有帳戶。
  2. 在 Google Analytics 中創建一個新的網站屬性,填寫網站 URL,並按照指示完成設置。
  3. 複製 Google Analytics 的跟蹤代碼。
  4. 登錄 WordPress 網站的後台管理系統,進入外觀 > 編輯器。
  5. 找到 functions.php 文件,並在檔案底部添加以下程式碼:
add_action('wp_head', 'wpb_add_googleanalytics');
function wpb_add_googleanalytics() { ?>
// 將複製的 Google Analytics 跟蹤代碼粘貼在此處
  1. 將複製的 Google Analytics 跟蹤代碼粘貼到上面程式碼的注釋部分。
  2. 保存 functions.php 文件。

完成這些步驟後,Google Analytics 就已經設置完成了,你可以開始使用它來監測網站的訪問量和其他數據。

English Version
  1. Log in to Google Analytics and create a new account or use an existing account.
  2. Create a new website property in Google Analytics, fill in the website URL, and follow the instructions to complete the setup.
  3. Copy the Google Analytics tracking code.
  4. Log in to the WordPress website’s admin dashboard, and go to Appearance > Editor.
  5. Find the functions.php file and add the following code at the bottom of the file:
add_action('wp_head', 'wpb_add_googleanalytics');
function wpb_add_googleanalytics() { ?>
// Paste the copied Google Analytics tracking code here
  1. Paste the copied Google Analytics tracking code into the commented section of the code above.
  2. Save the functions.php file.

After completing these steps, Google Analytics is fully set up, and you can start using it to monitor your website’s traffic and other data.

日本語版
  1. Google Analyticsにログインし、新しいアカウントを作成するか、既存のアカウントを使用します。
  2. Google Analyticsで新しいウェブサイトプロパティを作成し、ウェブサイトのURLを入力して、指示に従って設定を完了します。
  3. Google Analyticsのトラッキングコードをコピーします。
  4. WordPressウェブサイトの管理画面にログインし、外観 > エディターに移動します。
  5. functions.phpファイルを見つけ、ファイルの末尾に以下のコードを追加します:
add_action('wp_head', 'wpb_add_googleanalytics');
function wpb_add_googleanalytics() { ?>
// コピーしたGoogle Analyticsのトラッキングコードをここに貼り付けます
  1. コピーしたGoogle Analyticsのトラッキングコードを、上記コードのコメント部分に貼り付けます。
  2. functions.phpファイルを保存します。

これらの手順を完了すると、Google Analyticsの設定が完了し、ウェブサイトのアクセス数やその他のデータの監視を開始できます。

Ray Lee (System Analyst)
作者 Ray Lee (System Analyst)

iDempeire ERP Contributor, 經濟部中小企業處財務管理顧問 李寶瑞