CAOS | Host Google Analytics Locally

Mô tả

CAOS (Complete Analytics Optimization Suite) for Google Analytics allows you to host analytics.js/gtag.js/ga.js locally and keep it updated using WordPress’ built-in Cron-schedule. Fully automatic!

Bất cứ khi nào bạn chạy phân tích trang web của mình trên Google Pagespeed Insights hoặc Pingdom, nó sẽ gợi ý cho bạn tận dụng bộ nhớ cache của trình duyệt khi bạn đang sử dụng Google Analytics. Vì Google đã đặt thời gian hết hạn bộ nhớ cache thành 2 giờ. Plugin này sẽ giúp bạn có được điểm số cao hơn trên Pagespeed và Pingdom và giúp trang web của bạn tải nhanh hơn, bởi vì trình duyệt của người dùng không phải thực hiện một vòng để tải xuống tệp từ máy chủ bên ngoài của Google.

Just install the plugin, enter your Tracking-ID and the plugin adds the necessary Tracking Code for Google Analytics to the header (or footer) of your theme, downloads and saves the analytics.js/ga.js/gtag.js-file to your website’s server and keeps it updated (automagically) using a scheduled script in wp_cron(). CAOS is a set and forget plugin.

Please keep in mind that, although I try to make the configuration of this plugin as easy as possible, the concept of locally hosting a file or optimizing Google Analytics for Pagespeed Insights or GT Metrix has proven to be confusing for some people. If you’re not sure of what your doing, please consult a SEO expert or Webdeveloper to help you with the configuration of this plugin. Or hire me to do it for you.

For more information: How to setup CAOS.

Features

  • Host analytics.js, ga.js or gtag.js locally (What’s the difference?),
  • Endlessly extensible using the integrated filters and available mini plugins! E.g. track Google Adwords conversions and much, much more!
  • When using gtag.js, the underlying request to analytics.js is also hosted locally!
  • Bypass Ad Blockers in Stealth Mode: Sneak past Security and protect your Google Analytics data,
    • Plugins (e.g. linkid.js) are also served from a local source when in Stealth Mode!
    • CAOS Super Stealth Upgrade adds compatibility with Enhanced Commerce (ec.js) and gtag.js.
  • Preconnect to google-analytics.com to reduce latency and speed up requests,
  • Send an event to your Google Analytics dashboard when a visitor is viewing your pages using an Ad Blocker,
  • Capture outbound links,
  • Integrate Google Optimize,
  • Enhanced link attribution,
  • Allow tracking always or only when a certain cookie exists or has a value — Read more about GDPR Compliance,
  • Add tracking code to header, footer or manually,
  • Load the tracking snippet Asynchronous or Default (Synchronous)
  • Fully compatible with Google Analytics Dashboard Plugin for WP by MonsterInsights, WooCommerce Google Analytics Integration, Google Analytics Dashboard Plugin for WP by Analytify and Google Analytics Dashboard for WP by ExactMetrics,
  • Save analytics.js/ga.js/gtag.js anywhere within the WordPress content (wp-content) directory to avoid detection by WordPress security plugins (such as WordFence) or removal by caching plugins (such as WP Super Cache),
  • Serve analytics.js/ga.js/gtag.js from your CDN,
  • Set Cookie Expiry Period,
  • Set Adjusted Bounce Rate,
  • Change enqueue order (prioritize order of loaded scripts),
  • Enable Enhanced Link Attribution (linkid.js),
  • Force disabling display features functionalities,
  • Anonymize IP addresses,
  • Track logged in Administrators,
  • Manually update analytics.js/ga.js/gtag.js with the click of a button!

Cài đặt

  1. Tải các tệp của plugin lên thư mục /wp-content/plugins/host-analyticsjs-local hoặc cài đặt plugin trực tiếp thông qua trang plugin của WordPress.
  2. Kích hoạt plugin thông qua trang ‘Plugins’ (Gói mở rộng) trong WordPress
  3. Use the Settings -> Optimize Google Analytics screen to configure the plugin

Hỏi đáp

Tôi có một số tập tin muốn lưu ở local. Bạn có thể tạo một plugin cho chúng không?

Maintaining three plugins besides my daily 9-to-5 job is a handful, so no. If you’re looking for a way to host Google Webfonts locally; please install OMGF.. To host other 3rd party scripts and styles locally, try HELL. For WordPress Speed Optimization, check out WoOSH!

CAOS says analytics.js/gtag.js/ga.js isn’t updated in more than two days. What’s going on?

This is due to server configuration. Probably a permissions issue. It might be that PHP/WordPress isn’t allowed to create files programmatically. If you can upload media files just fine, then this probably isn’t the issue. Is your cron running? Try clicking the ‘update analytics.js/gtag.js/ga.js’ option to update the file manually. Meanwhile, contact your hosting provider so they can help you figure out if your cron is running correctly.

Can the gtm/js file used by Google Optimize be hosted locally?

No, it can’t. The gtm/js (or gtm.js) file is generated using a Client ID, which is unique for each visitor of your site. Saving this file locally would break your A/B tests.

I have disabled the plugin, but the Google Analytics tracking code is still added to the page. What’s going on?

This question has been asked on the support forum lots of times and in ALL cases it was caused by a Full Page Caching plugin, such as WP Fastest Cache or WP Super Cache, or another caching mechanism, such as Varnish. Possibly the page containing the snippet was cached in its entirety, and that cached version is still loading. Try flushing the plugin’s cache and empty your browser’s cache. Then reload the page.

After installing this plugin I’m getting a ‘Load resources from a consistent URL’-error on Google Pagespeed or GT Metrix. How can I fix this?

CAOS adds a modified version of the Google Analytics tracking code to your header or footer, depending on your settings. If you’re getting this notification (or optimization suggestion) this means that besides the GA tracking code added by CAOS, you’re also loading a second tracking code somewhere else in your blog. Possibly in your theme’s options or by another Google Analytics plugin. Remove/disable this and you’re good to go.

Plugin này có tuân thủ GDPR không?

Yes, it is! It is compatible with all WordPress Cookie Notice plugins which either set a cookie to allow tracking or set a certain value to a cookie to allow tracking. It’s completely customizable!

Google Tag Assistant nói rằng analytics.js bị lỗi. Điều này là bình thường?

Yes, this is normal. This browser extensions looks for this exact string ‘www.google-analytics.com/analytics.js’. Because with CAOS you’re hosting it locally, Tag Assistant doesn’t find this string and returns an error. However, you can still use Tag Assistant to verify tracking works.

Is CAOS compatible with WooCommerce?

Yes, it is! CAOS is compatible with several Google Analytics plugins for WooCommerce.

I use WP Super Cache / W3 Total Cache or another Caching and/or Minification plugin. Why is it removing analytics.js when I flush my cache?

This happens because analytics.js is saved within the ‘cache’-folder and for some reason the cache/minify plugin thinks it should be refreshed. Change the path where analytics.js is saved within CAOS to a path outside the /uploads/ folder (e.g. /uploads/caos/). This should resolve any issues you’re having.

WordFence (or another security plugin) is detecting file changes in analytics.js/gtag.js/ga.js. What’s going on?

This is perfectly normal, since this is the file that was updated by the built-in cronjob in older versions of CAOS. Update to the latest version and change the path where analytics.js is saved within CAOS to a path which is ignored by your security plugin (e.g. /uploads/ or /cache/). This should resolve any issues you’re having.

Khoảng thời gian cập nhật hiện tại của tập lệnh Analytics là gì?

I have set it to twice daily, because Google updates the script very often. If you suspect you might’ve gotten behind (which I doubt) Run a manual update button within CAOS’ settings.

Tôi đã tắt Báo cáo nhân khẩu học (Demographic Reports) trong Google Analytics, nhưng tập lệnh vẫn đang chuyển hướng đến doubleclick.net. Làm cách nào để tắt tính năng này?

Thử bật tùy chọn có tên “Tắt tất cả chức năng của tính năng hiển thị?” Khi tùy chọn này được bật, bạn có thể thực thi việc vô hiệu hóa plugin DisplayFeatures.

I’ve installed your plugin but analytics.js/ga.js/gtag.js is still showing up as an external request in Pingdom e.a.?

CAOS adds a local file called gtag.js/analytics.js/gtag.js (depending on your choice), which enables you to use Analytics, while hosting the necessary files locally. This doesn’t mean that it scans your entire plugins or themes directory for other manually/programatically added Analytics tracking-code. I.e. If analytics.js or ga.js is still showing up in the list of requests, this mean that something else (probably the theme you’re using or another plugin) is adding this tracking code to your WordPress Install. Find it. Remove it. And let CAOS take care of sending your needed data to Google Analytics.

Tôi sử dụng CDN. Tôi có thể sử dụng CAOS kết hợp với CDN của tôi không?

Yes, you can! Simply add the URL of your CDN within the advanced options and analytics.js/gtag.js/ga.js will be served from your CDN.

Đánh giá

2 Tháng Tám, 2020
Very nick job with the re-designed UI. Have used this plugins for years on multiple sites and always works great.
7 Tháng Sáu, 2020
This plugin does exactly what it's supposed to do and it's fantastic. The speed improvements recently have made this incredibly fast to load and collects all my tracking data as promised. Very happy with the support too. Daan has been fast to respond and extremely helpful. I would also recommend the premium plugin that extends CAOS functionality. For the price, it is well worth the investment.
7 Tháng Sáu, 2020
Amazing plugin. Very well explained and free! Really speed up the website. Daan offers a great and fast tech support. Thanks so much
Đọc tất cả 86 đánh giá

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

“CAOS | Host Google Analytics Locally” 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

“CAOS | Host Google Analytics Locally” đã được dịch qua 1 ngôn ngữ. Cảm ơn những người tham gia dịch vì đóng góp của họ.

Dịch “CAOS | Host Google Analytics Locally” sang ngôn ngữ của bạn.

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

Duyệt code, check out SVN repository, hoặc theo dõi nhật ký phát triển qua RSS.

Nhật ký thay đổi

3.6.0

  • CAOS now throws a notice if an Ad Blocker is enabled on CAOS’ admin screen, because Ad Blockers block any URL with ‘analytics’ in it, e.g. host-analyticsjs-local, which’ll cause manual updates to not work properly.
  • Added feature to send a custom event to Google Analytics when a page is viewed with an Ad Blocker enabled.
  • DNS-prefetch resource hint to google-analytics.com is now added automatically when Stealth Mode is disabled.
  • Changed CAOS’ default cache-path to /uploads/caos/
  • Minor refactors and code optimizations.

3.5.3

  • UX improvements and better notices.
  • Updated FAQ.

3.5.2

  • Some options in extensions tab are now hidden when Compatibility Mode is enabled.
  • Run cron twice daily to prevent schedule misses.

3.5.1

  • Added clearer descriptions for some settings in the Extensions tab.
  • Added more filter and action hooks.
  • Added fix for SameSite cookie policy for analytics.js and gtag.js. It’s not yet supported for linkid.js.

3.5.0

  • Plugins (e.g. linkid.js or ec.js) are now handled twice as fast with the new Extensions > Plugin Handling option set to Experimental Mode.
    • Mind you that loading ec.js in Stealth Mode requires CAOS Super Stealth Upgrade to work.

3.4.4

  • Added polyfill for is_plugin_active to fix Fatal Errors in certain WordPress configurations.

3.4.3

  • [HOTFIX] Fix for Fatal Error: Call to undefined function get_plugins().

3.4.2

  • Added notices for settings incompatible with (Super) Stealth Mode to increase UX.
  • CAOS Super Stealth Upgrade now supports gtag.js.
  • Minor code optimizations.

3.4.1

  • Fixed syntax errors in sidebar.

3.4.0

  • Code improvements for setting screen.
  • Added support for Enhanced Link Attribution (also works with (Super) Stealth.)
  • Added more filters and hooks for developers to extend CAOS.
  • Added support for Google Optimize (not compatible with Stealth Mode, and plugin file is not hosted locally, because file differs per user).
  • Fixed bug where notices would sometimes be displayed twice.
  • Added several notice to improve UX.

3.3.7

  • Added filter hooks for when Stealth mode is enabled/disabled, to improve UX.
  • Added filter hooks for tweet and review link, to improve UX.

3.3.6

  • Possible fix for Cron issues.

3.3.5

  • HOTFIX: Stealth Mode filter to be used for Super Stealth Mode.

3.3.4

  • Stealth Mode now respects the Anonymize IP setting.
  • Added some notices and reminders when some settings are changed, to improve UX.
  • Notices are now grouped.
  • When an update of the JS library is required after changing the settings, you will now be notified.

3.3.3

  • Added tabs in Settings to comply with WordPress plugin conventions == major code clean-up.

3.3.2

  • Admin screen is now responsive.
  • Sidebar scrolls on larger screens.

3.3.1

  • Fixed bug of paths to JS files for Capture Outbound Links and Admin JS.

3.3.0

  • Added new notices interface. Notices are now dismissible and CAOS now throws a global notice to notify you of issues with your analytics/gtag file.
  • Revamped settings screen with toggleable interface.

3.2.0

CAOS can now preconnect to google-analytics.com and CDN URL (if set).

3.1.3

Do not output success message when update-script is executed by CRON.
Added extra filter to allow further manipulation of the analytics.js tracking code.

3.1.2

Added filters on script elements.

3.1.1

CAOS now throws a notice if cURL is disabled on the server.

3.1.0

Added filter to add additional configuration using the gtag tracking snippet. Updated readme.txt.

3.0.1

Fixed bug where using Adjusted Bounce Rate would trigger two pageviews.

3.0.0

Major code overhaul. Major performance improvements.

2.9.4

Further improvements for downloading of analytics.js.

2.9.3

Fixed minor ‘ga is not defined’-bug when user is logged in.

2.9.2

Track outbound links doesn’t work when Stealth Mode is enabled. Added additional verification in settings form.

2.9.1

Forgot to add caos-frontend.js to SVN before committing previous version.

2.9.0

Tested with WP 5.3. Added new feature to track outbound links.

2.8.2

Replaced file_get_contents() and with cUrl to make CAOS compatible with servers that have allow_url_fopen disabled.

2.8.1

Code optimizations: the tracking code snippets can now be modified using add_filter(). CAOS’ own settings are also added using those filters.

2.8.0

Major overhaul of code to minimize plugin size and maximize performance.
[BUGFIX] the origin User-Agent is now passed to Google Analytics, instead of ‘WordPress’.

2.7.11

Severely improved performance of update-analytics script.

2.7.10

Apparently some servers require to die() after setting a location header in PHP.

2.7.9

Forgot a slash.

2.7.8

Damn Subversion. Had to add new file to versioning.

2.7.7

Stealth Mode now also works for Google Analytics Enhanced Link Attribution plugin.

2.7.5

Optimized Javascript.

2.7.4

UX improvements in Settings-area. Code re-factors.

2.7.3

Bugfix for ‘when cookie is set’-option. Added ‘when cookie is NOT set’-option. Code optimization for ‘when cookie has value’-option.

2.7.1

Bugfix for detecting user’s location when Stealth Mode is used.

2.7.0

Added new feature: Stealth Mode allows you to Bypass Ad Blockers and protects your Google Analytics data.

2.6.5

Code optimizations. Preparations for really cool (still secret) new feature!

2.6.4

Added compatibility with WooCommerce Google Analytics Integration!

2.6.3

Fixed ‘getCookieValue() is not a function.’-bug when using ‘Allow tracking’ options.

2.6.2

Fixed a bug where sometimes the default tracking code wasn’t loaded correctly.

2.6.1

CAOS can now be properly translated.

2.6.0

Added support for asynchronous loading of the snippet.

2.5.0

When using the gtag.js wrapper, the request to analytics.js is now also loaded from a local source!
Added link to explain differences between ga.js, analytics.js and gtag.js.

2.4.3/2.4.4

Oops! Forgot some strings!

2.4.2

Added translations and text domain according to WordPress’ requirements.

2.4.1

Changed name back to CAOS, because OMGF has its own shorthand now.

2.4.0

Added compatibility mode for Google Analytics Dashboard for WP by ExactMetrics. If you’re using any compatibility mode, the settings path has changed, so you need to set it again.

2.3.5

The cache-file and folder are now removed at plugin uninstall.

2.3.4

Added uninstall option and script.

2.3.3

Fixed minor console error

2.3.2

Fixed Adjusted Bounce Rate for gtag.js.

2.3.1

Fixed bug where sometimes wp-content directory wasn’t detected correctly.

2.3.0

Support for gtag.js added. Minor code optimizations.

2.2.2

Added option to cache ga.js locally, instead of analytics.js.

2.2.1

Updated Welcome Panel

2.2.0

Added CDN support

2.1.7

Changed URLs to new home: daan.dev

2.1.6

Added compatibility with Analytify for WordPress.

2.1.5

Added extra checks for PHP intl-module, which apparently isn’t enabled by default on all servers.

2.1.4

Bugfix for display of formatted Date/Time.

2.1.2

Fallback for servers who don’t have certain PHP date-modules installed.

2.1.1

Status bar now displays a date/time formatted according to locale chosen in WordPress.

2.1.0

Added status bar display cron and file health.

2.0.4

CAOS is now compatible with WordPress Multi Site.

2.0.3

Đã kiểm tra với WP 5+

2.0.2

Sửa lỗi không lưu được cài đặt.

2.0.1

Refactored code for includes to increase compatibility. Code optimizations. Renamed tasks to reflect code and name changes. Changed menu slug to reflect name changes.

2.0.0

Finally rid of the ugly versioning. Added settings link to plugins overview.

1.97

Sửa lỗi tương thích cho phiên bản PHP dưới 5.4.

1.95

Added option to change the directory where analytics.js is saved — relative to WordPress’ content directory (usually wp-content).

1.94

Fixed directory creation error. Removed notice from admin-screen, because it caused bugs on some systems.

1.93

Moved analytics.js to wp-content/cache to maximally optimize compatibility with WordPress security plugins.

1.91 / 1.92

Updated readme.txt. Refactored code and minor improvements.

1.90

Renamed local-ga.js to WordPress’ upload-directory and renamed it to analytics.js to make the file more recognizable for less experienced users.

1.85

Code optimizations and added function to trigger the update script manually.

1.83

Fixed bug where manually add tracking code wouldn’t show the tracking snippet.

1.82

Minor usability fixes.

1.81

Replace relative paths with absolute paths.

1.80

MAJOR UPDATE & Name change
Changed the name from Complete Analytics Optimization Suite to CAOS for Analytics. Because it’s cooler IMO.
CAOS is now compatible with Google Analytics by Monster Insights. This allows users of e-Commerce platforms such as WooCommerce to also locally host their analytics.js-file!

1.72

To improve compatibility with other plugins and themes, I added an option to add the snippet manually. So e.g. it can be added to a theme’s ‘custom head’ field or blocked until a Cookie Notice is approved.

1.70

UX optimizations in Admin-screen. Major code optimizations.

1.67

Bugfix.

1.66

Code optimizations.

1.65

Fixed bug in admin-screen, where new options weren’t always shown.
Code optimizations.

1.64

To maximize compatibility with other GDPR plugins I’ve added the option to choose whether to allow tracking when a certain cookie is set or when it has a certain value. Otherwise tracking will not be allowed.

1.61

Moved to Github.

1.60 – BUGFIXES

Fixed important bug where cookie value wasn’t read correctly, if user rejected cookies.
Code optimizations

1.56 – IMPROVEMENTS

Minor usability improvements.

1.55 – IMPROVEMENTS

Minor coding/performance/usability improvements.

1.53 – BUGFIX

Fixed important bug which would render the entire plugin useless if GDPR Compliance was disabled.

1.51 – Quickfix

Đã thêm tùy chọn cho phép vô hiệu hóa tất cả các chức năng GDPR một cách rõ ràng.

1.50 – New Features

Đã thêm tùy chọn để làm cho CAOS tuân thủ với quy định GDPR. Cảm ơn, Peter từ Applejack !
Tối ưu hóa và sửa lỗi nhỏ.
Đã cập nhật readme.txt để tuân thủ GDPR.

1.45

Đã cập nhật FAQ.
Đã thử nghiệm với các phiên bản WP mới nhất.

1.43

Đã thêm đối tượng địa lý để chỉ định URL thành CDN.
Đã cập nhật readme.txt.

1.42

Đã thêm tính năng để vô hiệu hóa plugin DisplayFeatures, vì đôi khi vô hiệu hóa tính năng này từ các tùy chọn trên Google Analytics là không đủ.

1.41

Thay đổi phiên bản, để đẩy nó qua trình cập nhật tự động trong WordPress.

1.40 – New Features

Đã thêm tùy chọn cho quản trị viên theo dõi. Nó hoàn toàn vô hiệu hóa mã cho các quản trị viên WordPress, tức là những người dùng khác đã đăng nhập trên trang web của bạn sẽ vẫn được theo dõi. Làm cho plugin hoàn toàn có thể dịch được. Đã làm một số tối ưu hóa mã.

PS. Just figured out I should’ve never used 1.36, as SVN now thinks 1.4 is an older version. So here we go, version 1.40 (Bluegh! I’ll do it right once we hit 2.0)

1.36 – Bugfixes

Với các tính năng mới này. Người hàng xóm ở Đức của tôi, Denis Abendroth, rất tử tế khi chỉ ra rằng tùy chọn IP ẩn danh đã được thêm vào theo thứ tự sai trong mã theo dõi. Vì vậy, tôi đã sửa nó ngay lập tức!

1.35 – New Features

Bản cập nhật này có nhiều IP yêu cầu Anonymize (@arcticblue, cảm ơn sự giúp đỡ của bạn!), Hiện đã được thêm vào bảng tùy chọn. Bên cạnh đó tôi đã tối ưu hóa mã một chút, loại bỏ khoảng 5 dòng mã.

1.32 – New Features

Đã thêm tùy chọn để thay đổi thứ tự enqueue của mã theo dõi. Bằng cách đó, người dùng có thể quyết định mức độ ưu tiên của mã theo dõi.

1.31 – Bugfixes

Đã khắc phục vấn đề Tỷ lệ thoát bị điều chỉnh: khi được bật, tính năng này sẽ phá vỡ mã theo dõi. Tôi đã thực hiện một số thay đổi mã nên đã khắc phục được vấn đề này, theo kịch bản được cung cấp bởi @BrianLeeJackson (Cảm ơn sự giúp đỡ của bạn!)

1.3 – New Features

Đã thêm tùy chọn cho tỷ lệ thoát được điều chỉnh
Đã thêm tùy chọn để tải ID theo dõi Analytics ở chân trang

1.2

Thay thế các thẻ PHP ngắn bằng ‘<?php’ thông thường để tăng khả năng tương thích. (Cảm ơn @burhandodhy!)

1.1

Đã cập nhật readme.txt và một số thay đổi mã tối thiểu để tăng UX.

1.0

Bản phát hành đầu tiên! Không có thay đổi nào cho đến nay!