Magento 2 GDPR Compliance: Anonymisation of order data

Installation and User Guide for Magento 2 GDPR Compliance: Anonymisation of Transaction Data Extension

Table of Contents

  1. Installation
    • Installation via app/code
    • Installation via Composer
  2. Configuration Settings for GDPR
    • General Settings
    • Order and Quote Anonymisation Settings
    • Privacy Settings
  3. Configuration Settings for Cookie Popup
    • General Settings
    • Popup Styling
    • Additional Tabs
  4. Admin Configuration for Manage Cookie Choices
    • Manage Choice List
    • Add New Cookie Choice
  5. Customers Details in Privacy Policy Consent
  6. Anonymize Orders from Admin Section
  7. Newsletter Subscription
  8. Enable / Disable Tracking Without GTM
    • Using Module
    • Manually Adding Code
  9. Integrate Cookies with GTM Pro Tracking
  10. Front-end Site View
    • Front-end Site View - Integrate Cookies with GTM Pro Tracking
    • Cookie Pop-up- Cookie Accept
    • Cookie Pop-up- Cookie Accept for different store views
    • Cookie Preferences
    • Check the Value of the Accepted Cookies on the Front-end
    • Visibility of "Accept All" Button on the Cookie Popup
    • Newsletter Subscription
    • Privacy Policy Checkbox on Registration and Checkout Page
    • Delete Account from My Account Section

Installation

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

https://docs.scommerce-mage.com/magento-2-extensions/installation-via-composer/installation-via-composer

Configuration Settings for GDPR

Go to Admin > Stores > Configuration > Scommerce Configuration > GDPR

General Settings

image - 2025-06-10T151317.120.png

image - 2025-06-10T151620.605.png

Order and Quote Anonymisation Settings

image - 2025-06-10T151732.655.png

Privacy Settings

image - 2025-06-10T151827.865.png

Configuration Settings for Cookie Popup

Go to Admin > Stores > Configuration > Scommerce Configuration > Cookie Popup

General Settings

image - 2025-06-10T151928.390.png

image - 2025-06-10T152025.799.png

Popup Styling

image - 2025-06-10T152104.515.png

image - 2025-06-10T152212.896.png

image - 2025-06-10T152250.618.png

Additional Tabs

image - 2025-06-10T152322.225.png

Admin Configuration for Manage Cookie Choices

image (55) (1).png

image (56) (1).png

Customers Details in Privacy Policy Consent

When customers check the privacy policy agreement checkbox in the process of registration then it saves the details of the customers in backend privacy policy consents at Admin > Customers > Privacy Policy Consent.

Privacy Policy Consent

image (73).jpg

Anonymize Orders from Admin Section

When you select action "Anonymise order" from Admin > Sales > Orders > Actions > Anonymise Order > Click on Submit button, then it anonymise customers data, which can't be reversed. Before "Submit" it asks for confirmation and displays a message popup says "Are you sure you want to anonymise selected transaction data because of this action can't be reversed?".

image (73).jpg

Newsletter Subscription

To see newsletter subscription records go to Admin > Marketing > Newsletter Subscription.

image (74).jpg

Enable / Disable Tracking Without GTM

Note:- Only implement this step if you are not using both our GTM and GDPR modules. If you are using both modules then you can set up consent mode v2 using the following guide:-

{% content-ref url="../analytics-and-tracking-extensions/magento-2-consent-modes-setup-guide.md" %} magento-2-consent-modes-setup-guide.md {% endcontent-ref %}

Using Module

You can enable or disable GTM tracking using cookies. We have provided an additional check in cookie setup which confirms whether GTM should be checked alongwith the cookie or not. when this check is enabled if the customer doesent accept the cookie then this tracking won't fire. If multiple cookies have the same option enabled then if any one of the cookie is accepted GTM will fire on the store.

Go to Customers>Manage Cookie Choices then create a new cookie or edit the existing one and set GTM to 'Yes'.

image (57) (1).png

Manually Adding Code

This section will cover Enabling or Disabling tracking without using Google Tag Manager. You can do that by including tracking function in your code, let us learn how. If you are using any of our tracking extensions or any other third party extension and you don't want to send information to Google then you need to check for the cookie name e.g. "statistics_cookie" and this will be set to 1 for "accept" and 0 for "decline", based on cookie value it will enable or disable the tracking.

In case you are using a third party extension then you need to add the code given below. This code needs to be added where your tracking has been implemented.

Here is the function which will force your tracking not to run unless the cookie has been accepted by the customer from cookie notification message.

e.g. You can add name of your GDPR cookie, here for our GDPR extension the name of cookie key is "statistics_cookie", which we have been using in below code. 

/** 
Check if has cookie with accepted cookie policy 
* 
@return bool 
*/ 
protected function hasCookie() 
{ 
/**
* @var \Magento\Framework\Stdlib\CookieManagerInterface 
*/ 
$cookie = (string)$this->_cookieManager->getCookie('statistics_cookie'); if ($cookie=="0"
{ return false; 
} 
else{ 
return true; 
} 
}

Integrate Cookies with GTM Pro Tracking

Note:- Only implement this step if you are not using both our GTM and GDPR modules. If you are using both modules then you can set up consent mode v2 using the following guide:-

{% content-ref url="../analytics-and-tracking-extensions/magento-2-consent-modes-setup-guide.md" %} magento-2-consent-modes-setup-guide.md {% endcontent-ref %}

You can integrate cookies with GTM Pro by following the below steps in GTM:-

Step 1 - The very first step is to create your cookie from the admin panel. To do that please refer to the 4th Part in this guide. The key thing to remember is the name of the cookie that you create in this step.

image (58) (1).png

Step 2 - The next step is to verify whether your cookie is working properly. Go on your website and accept or decline the cookie you have created in the begining. Now navigate to the Page inspector of your browser. Next go into application and then on the left navigation go to storage>cookies and then click on your website. A list of cookies will appear before you as you can see in the image. Now suppose you created a cookie named "Statistics_cookie" in the first step and have accepted it on the website then the value of this cookie will appear as 1. Vice versa if you have declined this cookie then the value will be 0.

image (75).jpg

Step 3 - Open google tag manager, go into variables section and Create a new variable named "statistics_cookie", variable type should be 1st-Party cookie and give the name of the cookie as "statistics_cookie". Keep in mind the name of the cookie should be exactly same as you have created in the admin panel. For instance, we created a cookie named "Statistics_cookie" so we have a variable named exactly same.

image (76).jpg

Step 4 - Now navigate to triggers in GTM and select a trigger and add a custom event as follows: -

image (59) (1).png

Step 5- Associate the trigger created in Step 4 with any of the existing tags and that tag will only fire when customer accepts the cookie on your website.

Front-end Site View

Front-end Site View - Integrate Cookies with GTM Pro Tracking

Let us see how it works on the front-end.

image (60) (1).png

image (77).jpg

image (78).jpg

Cookies are used to improve the experience for user. Once you accept, the file is added and the cookie helps analyse web traffic or lets you know when you visit a particular site. Cookies allow web applications to respond to you as an individual.

image - 2025-06-10T163459.473.png

Cookies are used to improve the experience for user. As we created different cookies for different store views we will see their behaviour on the frontend.

image (62) (1).png

image - 2025-06-10T163553.221.png

Check the Value of the Accepted Cookies on the Front-end

You can check the value of the accepted cookies by using developer tool (F12). Here is the path to check, Press F12 > Network > Storage > Cookies > Click on site URL > Check the cookies status/value under "Value" column.

When you "accept" cookies, the value will be set to "1".

image (79).jpg

When you "decline" cookies, the value will be set to "0" .

image (80).jpg

Visibility of "Accept All" Button on the Cookie Popup

The "Accept All" button will be shown on the cookie popup, if all cookie choices are not required and "Set by Default" for cookie choices set to "No" from Admin > Customers > Manage Cookie Choices > Manage Choice List > Select Cookie Choice > Edit >Set by Default - "Yes/No". If set to "Yes" then "Accept All" won't appear.

Newsletter Subscription

Once Enable Newsletter is configured from Admin > Stores > Configuration > Scommerce Configuration > GDPR > Privacy Settings > Enable Newsletter - "Yes" , then you can see the privacy agreement checkbox on the newsletter subscription. This is a mandatory option. Click on "Privacy Policy" link redirects to privacy policy page.

image (81).jpg

Privacy Policy Checkbox on Registration and Checkout Page

The privacy policy checkbox will be shown on the registration and checkout page.

image (82).jpg

Delete Account from My Account Section

You can delete the account from Front-end > My Account > Delete Account section.

image (83).jpg

If you have a question related to this extension please check out our FAQ Section first. If you can't find the answer you are looking for then please contact support@scommerce-mage.com**.*


Revision #4
Created 10 June 2025 09:29:20 by scommerce
Updated 24 October 2025 09:50:51 by scommerce