SiteMonetization
Adding a Rokt placement to your site is the first step for Rokt Ecommerce partners. Placements are flexible iframes that are used to display any type of Rokt campaign.
To set up a placement on your website, you can use the Web SDK (instructions below). Rokt also offers a range of mobile SDKs to set up placements on native Android, iOS, React Native, and Flutter applications.
Shopify stores can set up a Rokt placement in seconds using the Rokt Ecommerce app — no coding needed!
This guide is meant for websites built as multipage applications. If your site is a single page application, you should follow these instructions.
1. Load Rokt onto your page
Your account manager can provide your integration code, or you can find it in my.rokt.com.
Your integration code includes a customer identifier (we recommend raw email customer address) and data attributes. Read more about why Rokt asks for personal identifiers and data attributes.
Sample integration code
The first step to integrate with Rokt is to load Web SDK into your site. For the best performance, we encourage you to load Rokt script using the below structure.
If you are using Google Tag Manager, please make sure the document.write field is checked and see the recommended implementation steps.
If you are copying the below example, ensure rokt-account-id
is replaced with your account's unique ID. See Where can I find my Rokt ID? for instructions.
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta tags -->
<!-- Part #1 - Load the Web SDK -->
<script type="module">
window.RoktLauncherScriptPromise = new Promise((resolve, reject) => {
const target = document.head || document.body;
const script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://apps.rokt.com/wsdk/integrations/launcher.js";
script.fetchpriority = "high";
script.crossOrigin = "anonymous";
script.async = true;
script.id = "rokt-launcher";
script.addEventListener('load', () => resolve());
script.addEventListener('error', (error) => reject(error));
target.appendChild(script);
});
</script>
<!-- Other scripts and meta tags -->
</head>
<body>
<!-- Your HTML content here -->
<!-- Part #2 - As soon as the data attributes are available, execute the below script to display a Rokt placement -->
<script type="module">
await window.RoktLauncherScriptPromise;
const launcher = await window.Rokt.createLauncher({
accountId: "rokt-account-id",
sandbox: true,
});
await launcher.selectPlacements({
attributes: {
email: "",
firstname: "",
lastname: "",
confirmationref: "",
billingzipcode: "",
amount: "",
paymenttype: "",
ccbin: "",
mobile: "",
country: "",
language: "",
currency: "",
billingaddress1: "",
billingaddress2: "",
age: "",
gender: "",
cartItems: JSON.stringify(cartItems),
},
});
</script>
<!-- Your HTML content here -->
</body>
</html>
For the best performance, integrate the Web SDK early (e.g. in <head></head>
) and then activate the selectPlacements call as soon as data attributes are available to be integrated.
In the example above, sandbox: true
is used to test the integration in a sandbox environment. When you are ready to go live, set sandbox: false
or remove it altogether.
When you add the Web SDK to your page, please be sure to integrate data attributes, so you can serve customers the most relevant message available to them. This is typically a combination of both customer and transactional data. Your account manager can guide you through the optimal attributes to integrate depending on the vertical your business operates in.
Rokt recommends a direct integration as a best practice, but the option to integrate with a tag manager is available.
2. Set up pages and placements
The Rokt team will set up relevant pages and placements for you in One Platform. We can customize your placement to match your brand guidelines and UX needs.
Embedded placements
If you are planning to add an embedded placement to your site, you need to specify the HTML element that the placement should be anchored to. For example: <div id="rokt-placeholder"></div>
. Let the Rokt team know what element the placement should target.
3. Test your integration
Ensure that the Web SDK is loading on the right page and includes the correct attributes.
Read our guide on testing your integration.
If load speed issues exist, you may use a preparative iframe to solve this. You can read more about the benefits of the preparative iframe here.
More information
- General Web SDK reference
- Web SDK security
- Two-step data integration
- Encrypting attributes in transit
- Single page application integrations
Add a Rokt placement to your iOS, Android, React Native, or Flutter mobile applications.