Integrating the Web SDK
The Web SDK will need your Account ID on load. Your Account ID can be found in our platform:
- Log in to Rokt
- Click on ‘Tag’ in the left navigation
- You will see a sample snippet on the right hand side of the page that includes your Account ID in the correct place.
You can also contact your account manager.
Each Account has a different Account ID. If you are using multiple accounts, including nested parent/child accounts, double-check the Account IDs you’re using for each of your properties.
Understanding the Rokt Web SDK Object
The Rokt Object provides the entry point to integrate with Rokt solutions. It will be available as a global variable under a name specified in your snippet script. Your snippet script should resemble the following initialization code snippet:
(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','roktTagid', 'rokt');
Please notice the following important parameters in the arguments list above:
https://apps.rokt.com/wsdk/integrations/snippet.js
— is the URL pointing to the latest version of the Rokt Object.roktTagID
— represents your unique Rokt tag ID and should be replaced with the correct value.rokt
— is the name under which this object will be exposed on your window object, in this case it will be accessible usingwindow.rokt
or simplyrokt
.
In order to not interfere with your page loading the Rokt Object is asynchronously loaded. This means that at the time of running the above initialization snippet the full functionality exposed by the Rokt Object will not be available. Only the Rokt.onLoaded function is immediately available, while the rest of the functionality is added when the Rokt Object has been fetched and completely loaded. In order to be informed when you can start integrating fully, you can pass a callback function to Rokt.onLoaded as shown here.
rokt.onLoaded(function(rokt) {
// All functionalities described in this document are already available at this point of time.
rokt.setAttributes({
email: '',
});
});
See Rokt for more details on the Rokt Object and available methods.
See Rokt.setAttributes for more details on setting attributes.
Placing the Snippet
To place the snippet:
- Replace 'roktTagid' in the Rokt Object script with the unique ID for your account. Reach out to your account manager to assist in providing you with your Account ID.
- Add additional functions depending on your integration requirements. See below for links to examples of common integration scenarios.
- Add the script on the page(s) that you want to render placements on or drive conversions towards.
- Follow our recommended best practices to optimize page load times and performance outcomes
Conducting your QA with Rokt
The Rokt team will be on hand to verify that your integration works as expected.