Title: Analytics Head
Author: Łukasz Nowicki
Published: <strong>2011 年 6 月 18 日</strong>
Last modified: 2025 年 7 月 21 日

---

搜尋外掛

![](https://ps.w.org/analytics-head/assets/banner-772x250.png?rev=1559343)

![](https://ps.w.org/analytics-head/assets/icon-256x256.png?rev=1559343)

# Analytics Head

 由 [Łukasz Nowicki](https://profiles.wordpress.org/lukasznowicki/) 開發

[下載](https://downloads.wordpress.org/plugin/analytics-head.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/analytics-head/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/analytics-head/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/analytics-head/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/analytics-head/#developers)

 [技術支援](https://wordpress.org/support/plugin/analytics-head/)

## 外掛說明

This plugin adds tracking code for Google Analytics to your WordPress site. Unlike
other plugins, code is added to the <head> section, so you can authorize your site
in Google Webmaster Tools.

There are many Google Analytics plugins for WordPress. I used a few of those myself
and it worked well. The trouble began when I willed to use Google Webmaster’s Tools.

It turned out that I can authenticate the ownership of the website using my Google
Analytics account. Where’s the catch? Google Webmaster’s Tools expects that the 
code will be located at the <head> section and all the plugs have placed it at the
very end of the page (apart from this case – very rightly).

Therefore, I created a plug-in called “Analytics Head”, which places tracking code
in the <head> section of the web page. Of course you can put it in the footer at
any moment, if you like.

### Requirements

This plugin requires WordPress 4.0 (never forget to update your WP installation!)
and PHP 5.3 installed on your server. It is pretty uncommon to offer previous versions
of the PHP, however I must note that.

### Examples

Here are a few examples for developers

#### Actions

    ```
    add_action( 'pp_google_analytics_head_before', function() {
        echo '' . PHP_EOL;
        $of_course = 'I do not have to print here, I may do something else!';
    } );

    add_action( 'pp_google_analytics_head_after', function() {
        $i_just = 'printed google code...';
    } );
    ```

#### Filter

    ```
    add_filter( 'pp_google_analytics_head_output', function( $s ) {
        return str_replace( 'Google Analytics', 'Doodle Analytics', $s );
    } );
    ```

## 螢幕擷圖

 * [[
 * Google Analytics Head options panel.

## 安裝方式

 1. Upload `analytics-home` directory to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress
 3. Provide your Google ID in the Settings – Analytics Head section
 4. That’s all folks, have fun 🙂

## 常見問題集

### How do I get Google Tracking code?

Register at http://www.google.com/analytics/, add your site and then Google will
provide you valid Google Analytics code (something like UA-xxxxxxxx-y)

### Why do I need this code in the head section? Google told me that the code should be put just before tag

It is for Google Webmaster Tools users. You can prove that your site is owned by
you using Google code. However, in that case, Google will require that the code 
was placed in the “head” section of the site.

### Do I need to know how to use html, php or similar techniques?

No.

### What if I know php?

You may use following actions:

 * pp_google_analytics_head_before
 * pp_google_analytics_head_after

And one filter:

 * pp_google_analytics_head_output

Please note that those features are disabled by default. If you want to use them,
you must turn it on using plugin options page.

### Is it free?

Yes, it is under GPLv2 (and later) licence. However, you can donate me a few dollars
if it makes you feel good. I certainly have nothing against it.

## 使用者評論

![](https://secure.gravatar.com/avatar/1f227db699972251fcc076b245c491607a33877f87818e2661304ed8aedee248?
s=60&d=retro&r=g)

### 󠀁[Worked perfectly!](https://wordpress.org/support/topic/worked-perfectly-83/)󠁿

 [annavasconcellos](https://profiles.wordpress.org/annavasconcellos/) 2019 年 2 
月 16 日 1 則留言

It took me one minute to make the verification! Thank you!

 [ 閱讀全部 3 則使用者評論 ](https://wordpress.org/support/plugin/analytics-head/reviews/)

## 參與者及開發者

以下人員參與了開源軟體〈Analytics Head〉的開發相關工作。

參與者

 *   [ Łukasz Nowicki ](https://profiles.wordpress.org/lukasznowicki/)

[將〈Analytics Head〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/analytics-head)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/analytics-head/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/analytics-head/)，或透過 [RSS](https://plugins.trac.wordpress.org/log/analytics-head/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/analytics-head/)。

## 變更記錄

#### 1.7.0

 * Release date: 2025-07-21
 * Added support for GA4 (Google Analytics 4)
 * Retained support for UA (Universal Analytics) for compatibility purposes
 * Code refactoring

#### 1.6.7

 * Release date: 2018-11-21
 * Status: Stable
 * Set compatibility tag

#### 1.6.6

 * Release date: 2018-11-21
 * Status: Stable
 * Compatibility: 5.0 and previous
 * Small code refactoring
 * Some typo fixes

#### 1.6.5

 * Release date: 2018-05-18
 * Status: Stable
 * Compatibility: 4.9.6 and previous

#### 1.6.4

 * Release date: 2018-05-05
 * Status: Stable
 * Compatibility: 4.9.5 and previous

#### 1.6.3

 * Release date: 2018-05-05
 * Status: Stable
 * Changed hardcoded Google Analytics code

#### 1.6.2

 * Release date: 2017-10-12
 * Status: Stable
 * Compatibility: 4.8.2 and previous
 * Added new Google Analytics code

#### 1.6.1

 * Release date: 2017-08-03
 * Status: Stable
 * Compatibility: 4.8.1 and previous
 * Updated some assets

#### 1.6.0

 * Release date: 2016-11-19
 * Status: Stable
 * Compatibility: 4.7 and previous
 * Compatibility tested up with WordPress 4.7

#### 1.5.4.0

 * Release date: 2016-11-08
 * Status: Stable
 * Compatibility: 4.x and previous
 * Compatibility tested up with WordPress 4.6.1
 * Better options handling and versioning for builds

#### 1.5.3

 * Release date: 2016-11-08
 * Status: Stable
 * Compatibility: 4.x and previous
 * Compatibility tested up with WordPress 4.6.1
 * Better options handling

#### 1.5.2

 * Release date: 2016-11-08
 * Status: Stable
 * Compatibility: 4.x and previous
 * Compatibility tested up with WordPress 4.6.1
 * Getting rid of svn tags mess

#### 1.5.1

 * Release date: 2016-11-08
 * Status: Stable
 * Compatibility: 4.x and previous
 * Compatibility tested up with WordPress 4.6.1
 * We added missing method

#### 1.5.0

 * Release date: 2016-11-08
 * Status: Stable
 * Compatibility: 4.x and previous
 * Compatibility tested up with WordPress 4.6.1
 * This version is tested up with latest WordPress 4.6.1,
 * we changed donate link,
 * we get rid of previous ridicules versioning,
 * fixed some typos and updated translation.

#### 1.4.4.1

 * Release date: 2016-01-25
 * Status: Stable
 * Compatibility: 4.x and previous
 * Compatibility tested up with WordPress 4.4.1
 * Change way of versioning, instead of 0.MAIN.SUB pattern I will use MAIN.WPVERSION
   pattern – so now you know that subversion 4.4.1 is not a coincidence
 * Added two actions (pp_google_analytics_head_before, pp_google_analytics_head_after)
   and one filter (pp_google_analytics_head_output) – disabled by default, you may
   enable it in the admin panel.
 * Dropped 0.4.1 and previous settings check – those versions wasn’t available in
   WordPress repository
 * Version 0.6.0 loses 0.5.x settings. Now, if there are no 0.6 settings (blank 
   field) we will use 0.5 settings if available

#### 0.6.0

 * Release date: 2015-10-01
 * Status: Stable
 * Compatibility: 4.x and previous
 * Now you may hide your tracking code for all logged-in users
 * You may move your tracking code into footer instead of <head> section
 * This version requires at least PHP5.3

#### 0.5.6

 * Release date: 2015-05-17
 * Status: Stable
 * Compatibility: 4.x and previous
 * New Google Analytics code
 * Changed after_setup_theme hook with wp_loaded hook

#### 0.5.5

 * Release date: 2015-05-17
 * Status: Stable
 * Compatibility: 4.x and previous
 * Fixed problem with load_text_domain

#### 0.5.4

 * Release date: 2013-07-22
 * Status: Stable
 * Compatibility: 3.x and previous
 * Removed UTF leading info which can sometimes trigger ‘Headers already sent’ error.

#### 0.5.3

 * Release date: 2013-07-19
 * Status: Stable
 * Compatibility: 3.x and previous
 * On some installations, even after providing Google ID, you can see message to
   provide it.
 * Some minor bug-fixes and typo fixes.

#### 0.5.2

 * Release date: 2011-06-18
 * Status: Stable
 * Compatibility: 3.x and previous
 * On some machines, plugin can fire “wordpress Fatal error” – like many other plugins
   as I read on the net. It is fixed now.

#### 0.5.1

 * Release date: 2011-06-14
 * Status: Stable
 * Compatibility: 3.x and previous
 * Rewritten completely using OOP
 * Some minor bug-fixes
 * Removed trashy machine translations except polish (it isn’t machine)

#### 0.4.1

 * Release date: 2011-06-11)
 * Status: Release Candidate 1
 * Added ability to change the language
 * Added polish/german/french translations
 * Changed the way of saving the settings

#### 0.3

 * Release date: 2011-05-20)
 * Status: Beta
 * Rewritten completely just for fun
 * Some interface changes, no new functionality added

#### 0.2

 * Release date: 2011-04-09)
 * Status: Alpha
 * Added disabling for logged on admins

#### 0.1

 * Release date: 2011-04-08)
 * Status: Pre-alpha

## 中繼資料

 *  版本 **1.7.0**
 *  最後更新 **10 個月前**
 *  啟用安裝數 **700+**
 *  WordPress 版本需求 ** 5.0 或更新版本 **
 *  已測試相容的 WordPress 版本 **6.8.5**
 *  PHP 版本需求 ** 7.4 或更新版本 **
 *  語言
 * [English (US)](https://wordpress.org/plugins/analytics-head/)
 * 標籤:
 * [analytics](https://tw.wordpress.org/plugins/tags/analytics/)[google](https://tw.wordpress.org/plugins/tags/google/)
   [script](https://tw.wordpress.org/plugins/tags/script/)[tools](https://tw.wordpress.org/plugins/tags/tools/)
   [webmaster](https://tw.wordpress.org/plugins/tags/webmaster/)
 *  [進階檢視](https://tw.wordpress.org/plugins/analytics-head/advanced/)

## 評分

 5 星，滿分為 5 星

 *  [  1 個 5 星使用者評論     ](https://wordpress.org/support/plugin/analytics-head/reviews/?filter=5)
 *  [  0 個 4 星使用者評論     ](https://wordpress.org/support/plugin/analytics-head/reviews/?filter=4)
 *  [  0 個 3 星使用者評論     ](https://wordpress.org/support/plugin/analytics-head/reviews/?filter=3)
 *  [  0 個 2 星使用者評論     ](https://wordpress.org/support/plugin/analytics-head/reviews/?filter=2)
 *  [  0 個 1 星使用者評論     ](https://wordpress.org/support/plugin/analytics-head/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/analytics-head/reviews/#new-post)

[查看全部使用者評論](https://wordpress.org/support/plugin/analytics-head/reviews/)

## 參與者

 *   [ Łukasz Nowicki ](https://profiles.wordpress.org/lukasznowicki/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/analytics-head/)

## 贊助

想要支援這個外掛的發展嗎？

 [ 贊助這個外掛 ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZUE7KNWHW3CJ4)