Skip to main content

Preparative iframe

On a typical ecommerce web page, there is a long list of third-party technology services that are all competing to make network traffic calls, meaning that it can take time to get through the queue of requests. This increased competition between services can put strain on your page where load speed is critical to your customer experience.

To deliver the maximum value while incorporating best-in-class security and isolation, the Rokt Web SDK has been designed to make multiple requests between the server and browser. These series of requests, when combined with the requests made by other third-party services, can impact load times in certain circumstances.

We understand that load speed is vitally important, and the time it takes from when your page starts loading until the Rokt offer is shown has a direct impact on placement drop rates (missed transactions), impressions, engagement rates, and therefore value driven by Rokt.

Using the preparative iframe#

To combat this problem and provide a better customer experience, we’ve created a simple, easy to integrate add-on to the Web SDK integration. This solution consists of a secure, easy to implement, and flexible preparative iframe that can be implemented on an earlier page in your transaction flow.

To implement this solution, place the following code on any page in your transaction journey before the page where you display Rokt placements.

<iframe aria-hidden="true" src="" sandbox="allow-scripts allow-same-origin" style="border: 0px; width: 100%; display: none;"></iframe>

You can place the preparative iframe in a tag manager or within the body of the page. We recommend placing it on a page that customers spend more time on (like a shipping details page) to ensure the iframe can execute fully in the background before customers move on to the next page.

How it works#

The iframe downloads the majority of the Web SDK’s files and stores them in the browser’s cache to easily retrieve on a later page when it’s time to show the placement. Since all the iframe is doing is downloading the resources for later use, nothing is run on your page, and it requires no interaction with personal customer data. Once your customer lands on the page where the Rokt placement is shown, the Rokt service just needs to select, retrieve, and render the offers and placements.

By downloading the SDK in sections, you reduce the required network bandwidth required on time-sensitive pages. Using the preparative iframe solution shortens the placement load time resulting in an improved customer experience and better performance outcomes.


There are no security risks associated with integrating the iframe on an earlier page in the transaction flow (e.g., a payments page or shipping details page). The preparative iframe is completely separated from, and has no access to, your page. Iframes are special HTML elements that the browser engine enforces certain rules against. Functionally, iframes allow us to sandbox our logic, restricting our capabilities to only execute functionality within the iframe container, such as caching and contacting our API.

If code within an iframe requires additional privileges, such as access to personally identifiable information (PII) on the parent page, the application inside the iframe can only gain access by sending a message to the host page, with cooperative logic on the host page listening for these messages and responding at its discretion. Because there is no additional code on the host page cooperating with the iframe, nothing can respond, so the iframe cannot gain access to any information from the host page.

This isolation ensures that, if the Rokt code inside the iframe is somehow compromised, it does not have access to anything on the host page, and your customers’ data remains secure. Additionally, as the preparatory iframe doesn’t run any selection or targeting processes, no customer data is requested by Rokt at this stage.

Was this article helpful?