Skip to main content

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 Rokt 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!

Single page applications

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 contextual data. Read more about why Rokt asks for personal identifiers and contextual attributes.

Sample integration code

Loading the integration

The first step to integrate with Rokt is to load Rokt's Integration Launcher into your site. For the best performance, we encourage you to load Rokt script directly into your HTML head element by adding the following script tag.

Google Tag Manager

If you are using Google Tag Manager, please make sure the document.write field is checked and see the recommended implementation steps.

caution

If you are copying the below example, ensure roktAccountId is replaced with your account's unique ID. See Where can I find my Rokt ID? for instuructions.

<script type="module">
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";
target.appendChild(script);
await new Promise((resolve) =>
window.Rokt
? resolve()
: document
.getElementById("rokt-launcher")
.addEventListener("load", () => resolve())
);

const launcher = await window.Rokt.createLauncher({
accountId: "rokt-account-id",
sandbox: true,
});
await launcher.selectPlacements({
attributes: {
email: "",
firstname: "",
lastname: "",
mobile: "",
confirmationref: "",
amount: "",
currency: "",
paymenttype: "",
ccbin: "",
address1: "",
address2: "",
zipcode: "",
age: "",
gender: "",
country: "",
language: ""
},
});
</script>

You should opt in for one of these methods and ensure it executes only once.

2. Add the Rokt integration code to your site

Add the Rokt integration code from Step 1 between the HTML <head></head> tags of any page where you want to display a Rokt placement.

When you add the integration code to your page, make sure to populate customer and transactional data. Make sure you configure customer email address so that Rokt can identify customers and choose a relevant offer.

Populate any contextual attributes about the transaction to help Rokt better personalize what offers the customer sees.

note

Rokt recommends a direct integration as a best practice, but the option to integrate with a tag manager is available.

3. 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.

4. Test your integration

Ensure that the Rokt Web SDK is loading on the right page and includes the correct attributes.

Read our guide on testing your integration.

Preparative iframe

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

Native mobile app integrations

Add a Rokt placement to your iOS, Android, React Native, or Flutter mobile applications.

Was this article helpful?