이 플러그인은 최근 3개의 주요 워드프레스 출시와 시험 되지 않았습니다. 워드프레스의 좀 더 최근 버전으로 이용할 때 더 이상 관리되지 않고 지원되지 않고 호환성 문제가 있을 수 있습니다.

Multiple Google Analytics Trackers

설명

Minimalistic Google 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

스크린샷

  • Default settings with 1 tracker and the script printed in wp_footer()
  • Using multiple trackers and the custom hook for printing the script

설치

  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

FAQ

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
    });
  })
}

후기

2019년 2월 1일
#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.
2017년 3월 7일 1 reply
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
모든 3 평가 읽기

기여자 & 개발자

“Multiple Google Analytics Trackers”(은)는 오픈 소스 소프트웨어입니다. 다음의 사람들이 이 플러그인에 기여하였습니다.

기여자

“Multiple Google Analytics Trackers”(이)가 2(으)로 번역되었습니다. 기여해 주셔서 번역자님께 감사드립니다.

자국어로 “Multiple Google Analytics Trackers”(을)를 번역하세요.

개발에 관심이 있으십니까?

코드 탐색하기는, SVN 저장소를 확인하시거나, 개발 기록RSS로 구독하세요.

변경이력

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!