The best Google Analytics Integration for WordPress. Period.
Anyone is welcome to contribute to MonsterInsights. Please read the guidelines for contributing to this repository.
There are various ways you can contribute:
If you find an issue, let us know here!
This is a developer's portal for Google Analytics for WordPress by MonsterInsights and should not be used for support.
For the lite version please use monsterinsights.com Lite support.
For users of the pro version, please use the support form, located on the Support tab of the My Account page of our website (note: you must be logged in & have an active license to use this form).
Please report security issues to support@monsterinsights.com
Note all functionality on the admin side of the plugin, including any php/js/css functions, class names, files (or filenames), hooks or otherwise will not be garunteed backwards compatibility as a general rule. Our admin code is subject to change at any time without warning. As MonsterInsights is a frontend focused plugin, we're not too sure why you'd be building stuff with our backend code anyways. If you for some reason do need to use our backend code (anything located in admin or enqueued only in admin), please contact us with your usecase so we can adjust this policy and ensure your code will not break in the future.
For the frontend, we will not garuntee that the JS output will always be the same, nor can we, as we will adjust it over time to ensure continued Google Analytics compatibility and add features. However, we will garuntee the backwards compatibility of any hooks (filters or actions) found exclusively in the lite/includes/frontend
, pro/includes/frontend
, and includes/frontend
directories to the best of our abilities. These hooks are documented as such. Any sort of future breakage will be announced well in advance of any changes, and we'll try to never break anyone's use of these hooks.
MonsterInsights adheres to the WordPress core PHP standard with a couple deviations noted below. See https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/ for information on documenting using this standard.
elseif
, not else if
else if
as we do not permit use of the colon form of if else
, rendering Core's reason for this rule null. Colon forms of if else
are harder for text editors such as Sublime Text to parse the opening and closing of conditional logic, and thus are not permitted.true
or false
. Use the appropriate way of writing the if statement. if ( true == $var )
is equivolent to if ( $var )
and the latter is much easier to read. However when strict comparison is required (===
), one should use if ( true === $var )
.monsterinsights_
. The only exception to this is filters that need to be pro or lite only, in which case they should be proceeded by monsterinsights_pro_
and monsterinsights_lite_
respectively. Functions in a class should not be preceeded by monsterinsights_
. add_action
or add_filter
call(s) to a function shall be placed immediately after the end of a function declaration. For functions in classes, this rule does not apply as it is impossible to do this.++i
) instead of post-increments (i++
)
MonsterInsights is translation ready. Thanks to an extensive team of .org translators, much of the plugin is available translated into a wide variety of languages.
In googleanalytics-premium.php and in the /pro/ folder only use ga-premium
. Everywhere else use google-analytics-for-wordpress
.
MonsterInsights Lite uses WordPress.org provided translation files. MonsterInsights Pro loads the Lite translation files for files shared with Lite, and also loads Pro-only translation files for the Pro-only files. These files are created automatically from Pro translations. The latest copy of these files are pulled down and deployed with each Pro release.
Via the WordPress.org translation system located here.
Please open a issue for it.
A project goal of MonsterInsights, is to embrace automation whenever possible.
The MonsterInsights project taskrunner standard is Robo, and tasks for this project can be found in RoboFile.php (not available to public), and executed via: robo {command}
The entire deployment process, the thing that makes a new MonsterInsights version and releases it, is completely automated (no human interaction required) via Robo.
The MonsterInsights project dependency management system is Composer. Please make sure you don't accidentily override our composer file in your PRs.
We also use Node/NPM to manage packages used by our plugin primarily for admin styling and functionality.
We generally will always use the latest stable version of any Composer or NPM dependency, pulled and packaged during our automated release process, when possible. Some reasons we might use an out of date package include (but are not limited to):
When possible, we will always override/prefix all CSS rules, JS functions, and PHP class and function names in the dependencies we include when possible. With ~2 million active installs, not doing so is not an option (too many badly coded plugins out there). This process is completely automated, and done on release, between the step when composer/npm brings down the latest dependency versions, and when the zip files are autogenerated.
When possible, we will also minify all JS/CSS files from dependencies into a single file that gets used, except when there's compatibility issues, or if there's a bug in the parser of the CSS/JS minifier we use.
We do not maintain, nor have any current plans, to allow our plugin to be installed via Composer, Packagist, or other similar systems.
We also do not recommend you via direct code or a management system (such as via a GitHub repo download Composer package), assume our plugin, on any branch, will be the current and/or stable branch of our plugin.
The only official and maintained source of our plugin is on WordPress.org for the Lite version, and from the My Account area (or via the automatic updates) for the Pro version.
composer install
cd assets
npm update
The following constants can be defined in a wp-config file to allow for sections of MonsterInsights to be turned on and off across an installation base (and also for unit testing)
Plugin defined:
MONSTERINSIGHTS_VERSION
MONSTERINSIGHTS_PLUGIN_NAME
MONSTERINSIGHTS_PLUGIN_SLUG
MONSTERINSIGHTS_PLUGIN_FILE
MONSTERINSIGHTS_PLUGIN_DIR
MONSTERINSIGHTS_PLUGIN_URL
User defined:
MONSTERINSIGHTS_LICENSE_KEY
MONSTERINSIGHTS_FORCE_ACTIVATION
MONSTERINSIGHTS_AIRPLANE_MODE
MONSTERINSIGHTS_GA_UA
monsterinsights_get_ua
.MONSTERINSIGHTS_MULTISITE_GA_UA
.
MONSTERINSIGHTS_LITE_VERSION
MONSTERINSIGHTS_PRO_VERSION