
Collecting customer data in your store is a must if you want to deliver a personalised user experience. While you can track some data with default Magento cookies these are hardly enough to reach the goal.
That's when you resort to some services that help you collect more data and install extensions to deliver the message to visitors. But there is no need for so many resources if you can get all of these in one place — your admin panel — using the
.So, today you'll learn how to configure, create and track cookie consents in Magento. On top of that, you'll enable compatibility with Google Consent Mode with only one button.
Ready to start?
Post Contents [hide]
Create Magento Cookie Groups
Before you create any cookies in Magento, you should define the cookie groups you'll add them to. For that navigate to Marketing > Cookie Consent > Groups and hit the Add New Group button.
- Specify the group Name and Description that will be displayed on the frontend.
- Make the cookie group Active and assign it to Websites.
- Set whether this group is Required for visitors to accept.
- Define the Position of the group in the list of groups.
Note: if you have a multi-language store, translate the group name and description in the Store View Specific Name and Description sections.
Don't forget to Save the cookie group and move to the next step.
Create Magento 2 Cookies
Although the extension already includes the most common cookies, you can add as many new ones as you want. Go to Marketing > Cookie Consent > Cookie and start Adding New Cookie.
- Choose the Group ID where you want to include your cookie.
- Set the Cookie Code.
- Specify the cookie Name (provider) and Description that will be visible on the frontend.
- Make your cookie Active and set its Position in the list of cookies.
- Specify the cookie's Lifetime in days.
- Translate cookie names and descriptions in the Store View Specific Names and Descriptions sections if needed.
Save the cookie once you finish and check the cookie and cookie group on the frontend. You'll need to go to cookie settings to view them.
Configure Magento Cookie Consent Popup
Now that you have all the cookies and groups you need, it's time to display the Magento 2 cookie consent popup. However, you need to make sure it delivers the right message first. Go to Stores > Configuration > Magefan Extensions > Cookie Consent to fill out the settings.
GeoIP detection
You can display cookie consent popups depending on the region to personalize the experience of your target customers. For that go to the GeoIP Detection section and Enable cookie consent for Applicable Countries: All, EET or Specific Countries.
Cookie consent bar
Here you configure the cookie consent message and buttons:
- Title and Notification Text
- Accept/Decline/Settings Button Labels
That's what it looks like on the frontend:
Cookie consent popup settings
If visitors want to configure the cookies they accept, they go to settings. Configure buttons there too: Accept/Decline Button Labels.
Comply with Google Consent Mode
Now that you have the Magento 2 Cookie Consent Extension you don't need any third-party services to comply with the Google Consent Mode.
The extension already covers the essential parameters and sets the default status for them to DENIED. You can also add them to different cookie groups.
Track All Consents in Logs
Finally, once you fill out all the cookie consent settings, the extension will start tracking all the consents. But only if you tell it to. For that navigate to the Cookie Consent Log section and enable a corresponding option.
Then specify whether to Log Guest Cookie Consent and for how long to store the logs — Log Lifetime (in days).
Save the settings and go to Marketing > Cookie Consent > Log to view all collected consents.
How to Track Data if Cookies Are Denied?
You might be thinking — what is all this effort for if customers simply deny cookies? That's the right question to ask since denied cookies are one of the most common reasons for missing transactions in Google Analytics. But it doesn't have to be.
You just need to switch from client-side tracking to server-side. It sends data about users' behaviour from your server to GTM and Google Analytics 4. However, bypassing the cookie restrictions is not the only benefit.
Server-side tracking gathers data from multiple resources. So you're not only gathering all data — you're getting more detailed data. Give it a go to ensure you're collecting relevant data regardless of the cookie status.