WordPress plugin: Provides the integration between WooCommerce and Google Analytics.
Will be required for WooCommerce shops using the integration from WooCommerce 2.1 and up.
Google Analytics for WooCommerce utilizes npm scripts for task management utilities.
npm run build
- Runs the tasks necessary for a release. These may include building JavaScript, SASS, CSS minification, and language files.
- Install prerequisites: composer, git, xdebug, svn, wget or curl, mysqladmin
cd
into thewoocommerce-google-analytics-integration/
plugin directory- Run
composer install
- Run
bin/install-unit-tests.sh <db-name> <db-user> <db-pass> [db-host] [wp-version] [wc-version] [skip-database-creation]
e.g.bin/install-unit-tests.sh wordpress_test root root localhost latest latest
- Run
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text
to run all unit test
For more info see: WordPress.org > Plugin Unit Tests.
E2E testing uses wp-env which requires Docker.
Make sure Docker is running in your machine, and run the following:
npm run wp-env:up
- This will automatically download and run WordPress in a Docker container. You can access it at http://localhost:8889 (Username: admin, Password: password).
To install the PlayWright browser locally you can run:
npx playwright install chromium
Run E2E testing:
npm run test:e2e
to run the test in headless mode.npm run test:e2e-dev
to run the tests in Chromium browser.
To remove the Docker container and images (this will delete everything in the WordPress Docker container):
npm run wp-env destroy
release/*
branches or pushing changes to release/*
branches. To run it manually, please visit here and follow this instruction to do so.
- Run
composer install
(if you haven't done so already) - Run
npm run lint:php
Alternatively, run npm run lint:php:diff
to run coding standards checks agains the current git diff. An explanation of output can be found here e.g. what are the S's?
The extension sets up the default state of consent mode, denying all parameters for the EEA region. You can append or overwrite that configuration using the following snippet:
add_filter( 'woocommerce_ga_gtag_consent_modes', function ( $consent_modes ) {
$consent_modes[] =
array(
'analytics_storage' => 'granted',
'region' => array( 'ES' ),
);
$consent_modes[] =
array(
'analytics_storage' => 'denied',
'region' => array( 'US-AK' ),
);
return $consent_modes;
} );
After the page loads, the consent for particular parameters can be updated by other plugins or custom code, implementing UI for customer-facing configuration using Google's consent API (gtag('consent', 'update', {…})
).