OneTrust and Sitecore Integration Issues

OneTrust and Sitecore Integration Issues

By admin October 12, 2024

Introduction

We've been experiencing several issues with the integration of OneTrust and our Sitecore websites. Sometimes images fail to load, static JavaScript files are blocked, or even loaded twice. This has affected the functionality of our site, causing disruptions to key components. In this post, I’ll walk you through the challenges we've faced, especially regarding a pagination issue, and how we ultimately resolved it.

What is OneTrust?

For those unfamiliar, OneTrust is a platform that helps organizations comply with privacy regulations, including GDPR and CCPA, by managing cookie consent and data privacy settings. It categorizes cookies and scripts into different categories, such as essential, tracking, or marketing cookies, giving users control over which cookies are allowed to run on their browser.

Our OneTrust-Sitecore Integration

Our integration between OneTrust and Sitecore is customized. It includes functionality where content admins can input a OneTrust ID and specify categories of cookies and scripts via Sitecore settings. This allows for flexibility but also introduces complexity that can lead to issues, particularly when changes in cookie consent affect how scripts are loaded on the website.

The Pagination Issue

Recently, we encountered a major issue with our pagination component. Whenever users accepted cookies and refreshed the page, the pagination stopped working altogether. However, if we skipped tracking cookies, everything worked perfectly fine.

I spent hours investigating the problem, trying different configurations, debugging the JavaScript, and examining network calls. Eventually, I found the root cause: OneTrust was adding a category (c004) to our jquery.js script. At the end of the page load, this caused the script to reload—likely with an incorrect MIME type, such as text/plain instead of text/javascript. This misconfiguration broke the functionality of the pagination component, as the required scripts were not being executed properly.

The Final Solution

After much trial and error, the solution turned out to be simple: we needed to add the data-ot-ignore attribute to the <script> tag of jquery.js. This prevented OneTrust from modifying or reloading the script, ensuring that the correct version of the script loaded with the right MIME type.

By adding data-ot-ignore, we bypassed OneTrust’s interference with the script, and the pagination component started working flawlessly again.

Conclusion

Integrating OneTrust with Sitecore offers significant advantages in terms of cookie management and regulatory compliance. However, it can also introduce technical issues like blocked or reloaded scripts. In our case, OneTrust's script categorization disrupted key components of our site, such as pagination. Fortunately, the fix was straightforward once identified: adding the data-ot-ignore attribute to scripts we wanted to protect from OneTrust’s handling.

If you're facing similar challenges with OneTrust integration in Sitecore, make sure to carefully investigate how OneTrust is categorizing and managing your scripts, and consider using data-ot-ignore where appropriate to prevent such issues.

Featured Blogs