Web SDK Migration Guide
This guide explains how to migrate from older versions of the Rokt Web SDK (version 2.5926.0 or earlier) to the latest version. It’s relevant to both Rokt Ecommerce and Rokt Ads implementations, and walks you through breaking changes—like the updated initialization script—and how to coordinate with your Rokt account team to complete the migration smoothly.
Initializing the Web SDK
The biggest change introduced in the new SDK is how it's initialized within your website. Prior to the current version, Rokt allowed you to initialize, or load, the SDK by calling either the launcher.js
or snippet.js
scripts from the <head>
tags of each page in your site.
Both of these options have been replaced with a single initialization script.
Remove the deprecated launcher.js
script
Search your site's code and remove any instances of the launcher.js
script.
It should resemble:
<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>
Remove the deprecated snippet.js
auto launcher
If you used the auto launcher snippet, search your site's code and remove any instance of the script.
It should resemble:
(function (r, o, k, t, n, e, w, a, _) {
r._ROKT_ = n;
r[n] = r[n] || {
id: t,
h: w,
lc: [],
it: new Date(),
onLoaded: function (c) {
r[n].lc.push(c);
},
};
a = o.createElement("script");
a.type = "text/javascript";
a.async = !0;
a.src = k;
if (e) {
a.integrity = e;
a.crossOrigin = "anonymous";
}
_ = o.getElementsByTagName("script")[0];
_.parentNode.insertBefore(a, _);
})(
window,
document,
"https://apps.rokt.com/wsdk/integrations/snippet.js",
"roktAccountid",
"rokt"
);