Moments
JS SDK (for Websites)
11min
overview integrating momentscience into your online store, website, mobile app, or other user experience is designed to be easy and quick this guide will provide you with the needed steps to integrate our javascript sdk requirements before starting the integration process with the js sdk, ensure you have the following a momentscience account if you don't have one yet, sign up now "sdk id" (also known as "accountid") you can obtain it by following getting your sdk id docid\ zhe9uqnshwzsjo2aitskw steps overview the following playable demo will guide you through the steps required to integrate the momentscience javascript sdk with a website access the integration code navigate to the moments integration section and click "js sdk", here you can configure, view, download, and preview the javascript sdk, just copy the code provided to you integrate the code into your website paste the integration code provided by the momentscience dashboard from the previous step before closing the \</head> tag on your website before proceeding, ensure that the value in accountid in your integration code matches the one provided to you this ensures proper association with your momentscience account integration code example \<script type="module"> (function (window) { window\ adpxconfig = { // todo replace with your account's sdkid accountid 'your sdkid', autoshow true }; / fill this object with user specific values from your website or pass your custom key value pairs / window\ adpxuser = { // customer information properties here } })(window\ self !== window\ top ? window\ top window); (async function (window) { const target = window\ document head || window\ document body; const script = window\ document createelement('script'); script type = 'text/javascript'; script src = 'https //cdn pubtailer com/launcher min js'; script importance = 'high'; script crossorigin = 'anonymous'; script async = true; script id = 'adpx launcher'; target appendchild(script); await new promise(function (resolve) { window\ adpx ? resolve() window\ document getelementbyid('adpx launcher') addeventlistener('load', function () { resolve(); }) }); window\ adpx init(adpxconfig); })(window\ self !== window\ top ? window\ top window); \</script> initialization parameters the init function supports the following attributes name type description accountid string required your unique account id, use your sdk id learn how to getting your sdk id docid\ ogvi6 witurqhhu alue7 autoload boolean optional optional default true determines whether the momentscience sdk automatically fetches available offers when it's ready when set to false, you need to manually call the momentscience sdk's refresh function to fetch and display offers learn more about customization options docid\ zg5ko88gyuu0cxhno5chf autoshow boolean optional optional default true determines whether the offers overlay is automatically displayed when the momentscience sdk is ready when set to false, the momentscience sdk's show function must be called to trigger the offers overlay if autoload is set to false, autoshow does not have any effect learn more about customization options docid\ zg5ko88gyuu0cxhno5chf dev boolean optional optional default false enables testing mode will return offers for testing purposes but no activity will be recorded in this mode, geo targeting is ignored for publishers, ensuring that all offers are returned in offer responses for comprehensive testing settings object optional optional it can be used to override some dashboard settings and to configure the presentation of the moments unit learn more about customization options docid\ zg5ko88gyuu0cxhno5chf styles object optional optional it can be used to apply custom styling at runtime learn more about customization options docid\ zg5ko88gyuu0cxhno5chf initialization ( init ) configuration options must be specified within the properties of the window\ adpxconfig object setting init attributes window\ adpxconfig = { accountid 'your sdkid', //required autoload true, //optional autoshow false, //optional dev true, //optional settings {}, //optional styles {} //optional }; want to embed the web sdk into your website? check out our presentation options docid 8xm1u t8lcivrgphv7jgd to learn how passing in payload values with momentscience , you can easily pass payload values through the javascript sdk whether you're working on the server side or the client side, you have full control over the payload additionally, you can customize your payload by including your own key value pairs passing in payload values can enable the following offer personalization you can use passed payload values to personalize our offer messaging to making their experience more personal enhanced targeting with payload values, you can target offers more effectively, ensuring that the right content reaches the right audience customized reporting you can pass payload values to attribute your implementations to generate reports to segregate performance and give you deeper insights into your business performance supporting loyaltyboost offers payload values facilitate rewarding users for engaging with partners through loyaltyboost offers payload values are specified within the properties of the window\ adpxuser object you can fill in these values either by using a server side routine or by adding them client side before initializing the sdk with the window\ adpx init() call setting init attributes window\ adpxuser = { placement 'post transaction', firstname 'john', zipcode '74839', theme id 'moment post transaction', country 'us', adpx fp 'df983hgjdl9023klasjd', loyalty program id '23445665393' }; for detailed information about passing payload values using the js sdk, refer to passing payload values docid\ ymwqhfk a rt0lfya0etj verification of integration code 🎉 to ensure that your integration code has correctly been implemented visit the page containing the integration code to confirm that offers are displaying if you are passing payload values, verify that the preferred parameters are provided in the window\ adpxuser object 📢 if you're running into any issues while going through the integration process, feel free to contact us at help\@m omentscience com