Skip to content

Commit

Permalink
Merge pull request #3 from tagconcierge/feature/gtm-consent-mode
Browse files Browse the repository at this point in the history
Revamp for simple GTM consent mode
  • Loading branch information
michaloo authored Mar 5, 2024
2 parents 16cf9c5 + 87a7be5 commit 8a7b72c
Show file tree
Hide file tree
Showing 27 changed files with 598 additions and 376 deletions.
34 changes: 31 additions & 3 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
WORDPRESS_DB_HOST=mariadb
WORDPRESS_DB_USER=root
WORDPRESS_VERSION=latest
# To test on specific PHP version:
# WORDPRESS_VERSION=6.0.0-php8.0-apache

WORDPRESS_LOCALE=en_US

MYSQL_DATABASE=database
MYSQL_USER=user
MYSQL_PASSWORD=password
MYSQL_ROOT_PASSWORD=test

DB_HOST=mysql
DB_CHARSET=
DB_COLLATE=
TABLE_PREFIX=wp_

WP_DEBUG=true
WP_DEBUG_LOG=
WP_CACHE=
WPCACHEHOME=
UPLOADS=

FS_METHOD=
DISABLE_WP_CRON=
DISALLOW_FILE_EDIT=
TAR_OPTIONS=--no-same-owner
TAG_CONCIERGE_API_URL=https://beta-api.tagconcierge.com

WORDPRESS_DB_NAME=database
WORDPRESS_DB_USER=user
WORDPRESS_DB_PASSWORD=password
WORDPRESS_DB_NAME=wordpress
WORDPRESS_DB_HOST=mysql
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/.env
/dist
/vendor/
.wordpress_data
Binary file added assets/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "tagconcierge/gc-wordpress-plugin-free",
"name": "tagconcierge/gtm-consent-mode-banner-wordpress",
"type": "wordpress-plugin",
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"TagConcierge\\GtmCookiesFree\\": "src"
"TagConcierge\\GtmConsentModeBanner\\": "src"
}
},
"require-dev": {
Expand Down
26 changes: 17 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions dev/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ docker-compose run --rm -T php-cli <<INPUT
composer install --no-dev
rm -rf dist/
mkdir -p dist/gtm-cookies-free
mkdir -p dist/gtm-consent-mode-banner
cp gtm-cookies-free.php dist/gtm-cookies-free/
cp -R src dist/gtm-cookies-free/src
cp -R vendor dist/gtm-cookies-free/vendor
cp -R composer.* dist/gtm-cookies-free/
cp gtm-consent-mode-banner.php dist/gtm-consent-mode-banner/
cp readme.txt dist/gtm-consent-mode-banner/
cp -R src dist/gtm-consent-mode-banner/src
cp -R vendor dist/gtm-consent-mode-banner/vendor
cp -R composer.* dist/gtm-consent-mode-banner/
cd dist && zip -r gtm-cookies-free.zip gtm-cookies-free
cd dist && zip -r gtm-consent-mode-banner.zip gtm-consent-mode-banner
INPUT
69 changes: 48 additions & 21 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,64 @@
version: '2'
# dockerpresso 2.1.0
services:
wordpress:
image: wordpress:latest
web:
image: wordpress:$WORDPRESS_VERSION
env_file: .env
restart: always
volumes:
- ./.docker/wordpress:/var/www/html/
- .:/var/www/html/wp-content/plugins/gtm-cookies-free
- ./.wordpress_data:/var/www/html/
# uncomment line below to start theme development
# directory below should contain theme style.css file
# - ./example-theme-src:/var/www/html/wp-content/themes/example-theme
# uncomment line below to start plugin development
# directory below should contain main plugin PHP file
- .:/var/www/html/wp-content/plugins/gtm-consent-mode-banner
ports:
- "80:80"
links:
- mariadb
mariadb:
container_name: mariadb
image: mariadb:10.3
volumes:
- ./.docker/mariadb:/var/lib/mysql
- mysql
mysql:
image: mysql
restart: always
env_file: .env
environment:
MYSQL_DATABASE: wordpress
MYSQL_ROOT_PASSWORD: password
- MYSQL_DATABASE=${WORDPRESS_DB_NAME}
- MYSQL_USER=${WORDPRESS_DB_USER}
- MYSQL_PASSWORD=${WORDPRESS_DB_PASSWORD}
ports:
- "3306:3306"
cli:
volumes:
- mysql_data:/var/lib/mysql
web-cli:
profiles: ['cli']
image: wordpress:cli
env_file: .env
command: bash
volumes:
- ./docker/wordpress:/var/www/html/
user: "33:33"
env_file: .env
volumes_from:
- web
links:
- web
- mysql
mysql-cli:
profiles: ['cli']
image: mysql
env_file: .env
links:
- mysql:mysql
command: bash -c 'exec mysql -hmysql -uroot -p$$MYSQL_ROOT_PASSWORD $$MYSQL_DATABASE'
environment:
- MYSQL_DATABASE=${WORDPRESS_DB_NAME}
- MYSQL_USER=${WORDPRESS_DB_USER}
- MYSQL_PASSWORD=${WORDPRESS_DB_PASSWORD}
volumes_from:
- mysql
php-cli:
image: mfrankiewicz/php:7.1-cli
working_dir: /var/www
entrypoint: bash
profiles: ['cli']
image: composer
env_file: .env
command: bash
volumes:
- ./:/var/www
- .:/app
volumes:
mysql_data: {}

20 changes: 20 additions & 0 deletions gtm-consent-mode-banner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* Plugin Name: GTM Consent Mode Banner
* Plugin URI: https://wordpress.org/plugins/gtm-consent-mode-banner
* Description: Lightweight (1.9 kB) Consent/Cookies Banner compatible with GTM Consent Mode.
* Version: 1.0.0
* Author: Tag Concierge
* Author URI: https://tagconcierge.com/
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: gtm-consent-mode-banner
* Domain Path: /languages
*/

use TagConcierge\GtmConsentModeBanner\GtmConsentModeBanner;

require __DIR__ . '/vendor/autoload.php';

$plugin = new GtmConsentModeBanner();
$plugin->initialize();
20 changes: 0 additions & 20 deletions gtm-cookies-free.php

This file was deleted.

62 changes: 62 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
=== GTM Consent Mode Banner ===
Contributors: Tag Concierge
Tags: google tag manager, consent mode, cookies banner, privacy
Requires at least: 5.1.0
Tested up to: 6.2.2
Requires PHP: 7.0
Stable tag: 1.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Lightweight (1.9 kB) Consent/Cookies Banner compatible with GTM Consent Mode.

== Description ==

GTM Consent Mode Banner is a lightweight (1.9 kB), user-friendly WordPress plugin designed to integrate Google Tag Manager Consent Mode seamlessly into your website. It offers a simple and efficient way for website owners to comply with cookie and privacy regulations like GDPR and CCPA, by enabling visitors to select their cookie preferences easily.

## Features

- **Simple Setup**: Integrate with Google Tag Manager with minimal configuration.
- **Customizable Consent Banner**: Tailor the appearance and message of your consent banner.
- **User Preference Control**: Allows users to specify their consent for different types of cookies (e.g., necessary, analytics, marketing).
- **Compliance with Privacy** Laws: Helps in making your website compliant with GDPR, CCPA, and other privacy regulations.
- **Lightweight and Fast**: Designed to be non-intrusive and does not affect your website's load time.


== Installation ==

1. Upload or install `GTM Consent Mode Banner` plugin from WordPress plugins directory.
2. Activate the plugin through the `Plugins` menu in WordPress.
3. That's it! Consent State will be pushed to DataLayer adhering to Consent Mode API
4. Use plugin settings to customise the content and consent settings.
5. Optionally use plugin settings to install GTM snippets

== Frequently Asked Questions ==

= How to inject GTM tracking snippet? =

By default this plugin push consent information to the GTM DataLayer object that can be installed by other plugins or directly in the theme code.
It can also embed GTM snippets, go to settings to configure it.

= Do I need to configure anything in GTM to enable consent mode =

Once your Consent Banner is deployed you need to review all your GTM tags to ensure they have correct consent checks settings.
You can use Consent Overview screen to quickly review and update tags. [Read more here](https://docs.tagconcierge.com/article/59-how-to-configure-gtm-consent-mode)

== Screenshots ==

1. Consent Banner in action
2. Consent Banner displayed as modal
3. Consent Banner displayed as bar without "wall"
4. Consent Banner settings screen with all consent types listed
5. Consent Banner WP Admin basic settings
6. Consent Banner WP Admin banner content settings
7. Consent Banner WP Admin GTM snippets settings
8. Consent Banner WP Admin consent types settings


== Changelog ==

= 1.0.0 =

* Initial version
12 changes: 6 additions & 6 deletions src/DependencyInjection/Container.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace TagConcierge\GtmCookiesFree\DependencyInjection;
namespace TagConcierge\GtmConsentModeBanner\DependencyInjection;

use TagConcierge\GtmCookiesFree\Service\GtmSnippetService;
use TagConcierge\GtmCookiesFree\Service\SettingsService;
use TagConcierge\GtmCookiesFree\Util\OutputUtil;
use TagConcierge\GtmCookiesFree\Util\SettingsUtil;
use TagConcierge\GtmConsentModeBanner\Service\GtmConsentModeService;
use TagConcierge\GtmConsentModeBanner\Service\SettingsService;
use TagConcierge\GtmConsentModeBanner\Util\OutputUtil;
use TagConcierge\GtmConsentModeBanner\Util\SettingsUtil;

class Container
{
Expand All @@ -21,7 +21,7 @@ public function __construct()
{
$this->outputUtil = new OutputUtil();
$this->settingsUtil = new SettingsUtil();
$this->gtmSnippetService = new GtmSnippetService($this->settingsUtil, $this->outputUtil);
$this->gtmSnippetService = new GtmConsentModeService($this->settingsUtil, $this->outputUtil);
$this->settingsService = new SettingsService($this->settingsUtil);
}

Expand Down
19 changes: 19 additions & 0 deletions src/GtmConsentModeBanner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace TagConcierge\GtmConsentModeBanner;

use TagConcierge\GtmConsentModeBanner\DependencyInjection\Container;

class GtmConsentModeBanner
{
public const SNAKE_CASE_NAMESPACE = 'gtm_consent_mode_banner';

public const SPINE_CASE_NAMESPACE = 'gtm-consent-mode-banner';

private $container;

public function initialize()
{
$this->container = new Container();
}
}
19 changes: 0 additions & 19 deletions src/GtmCookiesFree.php

This file was deleted.

Loading

0 comments on commit 8a7b72c

Please sign in to comment.