Title: Multiple Google Analytics Trackers
Author: Ahrengot
Published: <strong>2 Tháng 11, 2016</strong>
Last modified: 11 Tháng 9, 2017

---

Tìm kiếm plugin

Plugin này **chưa được cập nhật với 3 phiên bản mới nhất của WordPress**. Nó có 
thể không được hỗ trợ và bảo trì, và có thể xung đột với các phiên bản WordPress
mới nhất.

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

# Multiple Google Analytics Trackers

 Bởi [Ahrengot](https://profiles.wordpress.org/ahrengot/)

[Tải về](https://downloads.wordpress.org/plugin/multi-google-analytics.1.1.2.zip)

 * [Chi tiết](https://vi.wordpress.org/plugins/multi-google-analytics/#description)
 * [Đánh giá](https://vi.wordpress.org/plugins/multi-google-analytics/#reviews)
 *  [Cài đặt](https://vi.wordpress.org/plugins/multi-google-analytics/#installation)
 * [Nhà phát triển](https://vi.wordpress.org/plugins/multi-google-analytics/#developers)

 [Hỗ trợ](https://wordpress.org/support/plugin/multi-google-analytics/)

## Mô tả

Minimalistic [Google Analytics](http://www.google.com/analytics/) plugin that lets
you add one or more trackers and control exactly how the script is rendered.

#### Rendering the script

This plugin lets you control wether the Google Analytics script is printed in the`
<head>`-element, the `<body>`-element or using a custom action.

There’s also a filter available, if you want to completely override the code that
prints the analytics code. This way you can use the plugin simply for storing the
property ID’s in the database and manually render the analytics script exactly as
your want it.

The filter for overriding the script code is `ahr-google-analtyics/script_file_path`
and you’d use it like so:

    ```
    add_filter('ahr-google-analtyics/script_file_path', function($default_path){
        // return an absolute file path to the file you want to use for rendering the script
    }, 10, 1);
    ```

#### Accessing the property ids via code

If you need to manipulate the Google Analytics property ids before they are printed,
then use the `ahr-google-analtyics'/property_ids` filter. It’ll pass you an array
of property ids as its single argument.

If you need to pull the ids from the database, in any other context, you can use`
$property_ids = get_option( AhrGoogleAnalytics::OPTION_IDS );`

This plugin will always give you an array of ids. Even if you just have one.

#### Source code & contributions

Please feel free to contribute improvements, report bugs or suggest new features
via the GitHub repo

 * [Github Repo](https://github.com/Ahrengot/multiple-google-analytics)
 * [Suggest improvements](https://github.com/Ahrengot/multiple-google-analytics/issues)
 * [Open a pull request](https://github.com/Ahrengot/multiple-google-analytics/pulls)

## Ảnh màn hình

[⌊Default settings with 1 tracker and the script printed in wp_footer()⌉⌊Default
settings with 1 tracker and the script printed in wp_footer()⌉[

Default settings with 1 tracker and the script printed in wp_footer()

[⌊Using multiple trackers and the custom hook for printing the script⌉⌊Using multiple
trackers and the custom hook for printing the script⌉[

Using multiple trackers and the custom hook for printing the script

## Cài đặt

 1. Move the `ahr-google-analytics` folder to the `/wp-content/plugins/` directory 
    OR search for ‘Multiple Google Analytics’ and add the plugin using WordPress’ plugin
    browser.
 2. Activate the plugin through the ‘Plugins’ page in WordPress
 3. Add one or more web property IDs (UA-XXXXXXX-X strings) on the settings page

## Hỏi đáp

  Installation Instructions

 1. Move the `ahr-google-analytics` folder to the `/wp-content/plugins/` directory 
    OR search for ‘Multiple Google Analytics’ and add the plugin using WordPress’ plugin
    browser.
 2. Activate the plugin through the ‘Plugins’ page in WordPress
 3. Add one or more web property IDs (UA-XXXXXXX-X strings) on the settings page

  What is a Google Analytics property ID?

It’s the string looking like `UA-XXXXXXX-X` next to your website URL on https://
analytics.google.com/analytics/web/

  JavaScript: How do I track pageviews/events/etc. using multiple trackers

If you’re building a JavaScript-based web app and manually need to track custom 
routes or events you can use the `ga.getAll()` method to get an array of registered
trackers and then run the tracking logic for each tracker.

For example, this will track page views based on custom routes:

    ```
    if ( typeof ga === 'function' && typeof ga.getAll === 'function' ) {
      ga.getAll().forEach(tracker => {
        tracker.set('page', *my-custom-route*); // Custom route e.g. '/my-page'
        tracker.send('pageview');
      })
    }
    ```

And here’s an example of tracking custom events:

    ```
    if ( typeof ga === 'function' && typeof ga.getAll === 'function' ) {
      ga.getAll().forEach(tracker => {
        tracker.send('event', {
          eventCategory: 'Search',
          eventAction: 'Query',
          eventLabel: *query*, // Your search query
          eventValue: *matches.length* // Optionally, send the number of matches for the query
        });
      })
    }
    ```

## Đánh giá

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

### 󠀁[Fatal Error while activating and button “add new property” not working](https://wordpress.org/support/topic/fatal-error-while-activating-and-button-add-new-property-not-working/)󠁿

 [turboy](https://profiles.wordpress.org/turboy/) 1 Tháng 2, 2019

#1st server WP 5.0.3 PHP 5.4 After installation if i click on Activate I get this:
Fatal error: Can’t use function return value in write context in /your-wp-installation/
wp-content/plugins/multi-google-analytics/google-analytics.php on line 163 #2nd 
server WP 4.3.3 PHP 5.X Got it installed via wp-cli, but then I can’t add more than
one property code, because the button “add new property” is not working. I had to
inject the code editing the HTML table (via “F12” on Chrome) and adding a new row.
Then save it.

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

### 󠀁[Plugin do not work](https://wordpress.org/support/topic/plugin-do-not-work-2/)󠁿

 [quivi](https://profiles.wordpress.org/quivi/) 7 Tháng 3, 2017 1 trả lời

Fatal error: Can’t use function return value in write context in /domains/paintballfactory.
pl/public_html/wp-content/plugins/multi-google-analytics/google-analytics.php on
line 49

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

### 󠀁[Works as intended!](https://wordpress.org/support/topic/works-as-intended-61/)󠁿

 [Anders](https://profiles.wordpress.org/anderrs/) 7 Tháng 11, 2016

The plugin works as intended.

 [ Đọc tất cả 3 đánh giá ](https://wordpress.org/support/plugin/multi-google-analytics/reviews/)

## Người đóng góp & Lập trình viên

“Multiple Google Analytics Trackers” là mã nguồn mở. Những người sau đã đóng góp
vào plugin này.

Những người đóng góp

 *   [ Ahrengot ](https://profiles.wordpress.org/ahrengot/)

“Multiple Google Analytics Trackers” đã được dịch qua 3 ngôn ngữ. Cảm ơn [những người tham gia dịch](https://translate.wordpress.org/projects/wp-plugins/multi-google-analytics/contributors)
vì đóng góp của họ.

[Dịch “Multiple Google Analytics Trackers” sang ngôn ngữ của bạn.](https://translate.wordpress.org/projects/wp-plugins/multi-google-analytics)

### Muốn tham gia phát triển?

[Duyệt code](https://plugins.trac.wordpress.org/browser/multi-google-analytics/),
check out [SVN repository](https://plugins.svn.wordpress.org/multi-google-analytics/),
hoặc theo dõi [nhật ký phát triển](https://plugins.trac.wordpress.org/log/multi-google-analytics/)
qua [RSS](https://plugins.trac.wordpress.org/log/multi-google-analytics/?limit=100&mode=stop_on_copy&format=rss).

## Nhật ký thay đổi

#### 1.1.2

Release Date: September 11th, 2017

Add support for the new longer google analytics ID’s that would previously be rejected
by the validator

#### 1.1.1

Release Date: March 15th, 2017

Fixes a bug where default values weren’t set properly when first activating plugin

#### 1.0.1

Release Date: December 11th, 2016

Fixes typos in plugin activation/deactivation callback functions

#### 1.0.0

Release Date: November 2nd, 2016

 * Initial release. Yay!

## Meta

 *  Phiên bản **1.1.2**
 *  Cập nhật lần cuối **9 năm trước**
 *  Số lượt cài đặt **60+**
 *  Phiên bản WordPress ** 4.0 hoặc cao hơn **
 *  Đã kiểm tra lên đến **4.8.28**
 *  Ngôn ngữ
 * [Danish](https://da.wordpress.org/plugins/multi-google-analytics/), [English (US)](https://wordpress.org/plugins/multi-google-analytics/),
   [Spanish (Chile)](https://cl.wordpress.org/plugins/multi-google-analytics/), 
   và [Spanish (Spain)](https://es.wordpress.org/plugins/multi-google-analytics/).
 *  [Dịch sang ngôn ngữ của bạn](https://translate.wordpress.org/projects/wp-plugins/multi-google-analytics)
 * Thẻ
 * [analytics](https://vi.wordpress.org/plugins/tags/analytics/)[google](https://vi.wordpress.org/plugins/tags/google/)
   [google analytics](https://vi.wordpress.org/plugins/tags/google-analytics/)[statistics](https://vi.wordpress.org/plugins/tags/statistics/)
   [stats](https://vi.wordpress.org/plugins/tags/stats/)
 *  [Nâng cao](https://vi.wordpress.org/plugins/multi-google-analytics/advanced/)

## Đánh giá

 3.7 trên 5 sao.

 *  [  2 5-star reviews     ](https://wordpress.org/support/plugin/multi-google-analytics/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/multi-google-analytics/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/multi-google-analytics/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/multi-google-analytics/reviews/?filter=2)
 *  [  1 1-star review     ](https://wordpress.org/support/plugin/multi-google-analytics/reviews/?filter=1)

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

[Xem tất cả đánh giá](https://wordpress.org/support/plugin/multi-google-analytics/reviews/)

## Những người đóng góp

 *   [ Ahrengot ](https://profiles.wordpress.org/ahrengot/)

## Hỗ trợ

Có điều gì muốn nói? cần giúp đỡ?

 [Xem diễn đàn hỗ trợ](https://wordpress.org/support/plugin/multi-google-analytics/)