Moments
JS SDK (for Websites)
adspostx is now momentscience! momentscience! 🎉 we have rebranded adspostx to momentscience all the latest documentation and updates can now be found at momentscience documentation https //docs momentscience com/ introduction integrating adspostx 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 an adspostx account if you don't have one yet, sign up now an "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 adspostx 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 adspostx 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 adspostx 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\ zhe9uqnshwzsjo2aitskw autoload boolean optional optional default true determines whether the adspostx sdk automatically fetches available offers when it's ready when set to false, you need to manually call the adspostx sdk's refresh function to fetch and display offers learn more about customization options docid\ wyj72s9wwg5y bddpsm3 autoshow boolean optional optional default true determines whether the offers overlay is automatically displayed when the adspostx sdk is ready when set to false, the adspostx 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\ wyj72s9wwg5y bddpsm3 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\ wyj72s9wwg5y bddpsm3 styles object optional optional it can be used to apply custom styling at runtime learn more about customization options docid\ wyj72s9wwg5y bddpsm3 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\ lufwrkz7xnpz yblemhod to learn how passing in payload values with adspostx, you can easily pass payload values through the javascript sdk whether you're working on the server side or 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 = { email 'user\@domain com', firstname 'john', zipcode '74839', theme id 'adspostx post transaction', country 'us', adpx fp 'df983hgjdl9023klasjd', placement 'post transaction', loyalty program id '23445665393' }; for detailed information about passing payload values using the js sdk, refer to passing payload values docid 4xbsdmzcxki2b4tfkrjji 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\@adspostx com