### Example Postback URL (Get Method) Source: https://docs.adspostx.com/api/handling-postback-events This URL illustrates the GET method for handling postback events, where all relevant event information is appended directly as query parameters. This approach simplifies data retrieval and parsing as no separate request body needs to be processed. ```URL https://postback.domain.com/pb?payout=2.10×tamp=2023-09-20T15:27:40.802Z&offer id=1511&advertiser name=adspostx&is loyaltyboost=0&confirmationref=a90310222&user id=3410444 ``` -------------------------------- ### Basic Perkswall URL Example Source: https://docs.adspostx.com/api/perkswall This example demonstrates a basic implementation of the Perkswall by linking to a standalone URL. Publishers need to pass their SDK ID into the 'accountid' parameter. ```URL https://get.perkswall.com/offerwall?accountid=99e58babc94df55a ``` -------------------------------- ### Install React Native Dependency Packages Source: https://docs.adspostx.com/api/react-native This command installs the necessary dependency packages, 'axios' for making API calls and 'react-native-device-info' for obtaining device-related information, which are essential for integrating the Adspostx Moments API into your React Native application. ```Shell npm install axios react-native-device-info ``` -------------------------------- ### JavaScript SDK `init` Configuration Example Source: https://docs.adspostx.com/api/js-sdk-for-websites This code snippet demonstrates how to configure the `window.adpxconfig` object with various initialization parameters for the momentscience SDK, including required and optional settings like `accountid`, `autoload`, `autoshow`, `dev`, `settings`, and `styles`. ```JavaScript window.adpxconfig = { accountid: 'your sdkid', //required autoload: true, //optional autoshow: false, //optional dev: true, //optional settings: {}, //optional styles: {} //optional }; ``` -------------------------------- ### Example Call to Fetch Moment Offers Data Source: https://docs.adspostx.com/api/react-native This snippet demonstrates how to call the 'fetchmomentoffers' wrapper function with specific query parameters and payload. It includes a 'dev' parameter for enabling the sandbox environment during testing and shows how to pass a unique user identifier ('adpx_fp') for user tracking. ```JavaScript const fetchdata = async () => { const queryparameters = {loyaltyboost: '0', creative: '0'}; const payload = { // 'dev': '1' enables sandbox environment and // returns offers for testing purposes; no activity is recorded // use '1' while testing only and not in production 'dev': '1', // replace the value of 'adpx_fp' with your // unique user identifier (customer id, user id, etc) 'adpx_fp': (await generateuniqueid()).toString(), }; try { const result = ``` -------------------------------- ### JavaScript SDK Website Integration Example Source: https://docs.adspostx.com/api/js-sdk-for-websites This snippet provides the full JavaScript code required to integrate the momentscience SDK into a website. It initializes the SDK with a placeholder `accountid` and demonstrates how the SDK script is dynamically loaded and initialized before the closing tag. ```JavaScript ``` -------------------------------- ### Adspostx Offers Unit: Container Style Override Example Source: https://docs.adspostx.com/api/customization-options Example code demonstrating how to customize the main container of the offers unit, including background color, border radius for all corners, shadow, and image position. ```APIDOC styles { //customize the offers unit container popup { background "#ffffff", borderradius { bottom left "12", bottom right "12", top left "12", top right "12" }, shadow "#8f8f8f", image position "left", } } ``` -------------------------------- ### Example Adspostx API Offer Response Source: https://docs.adspostx.com/api/perkswall-api A sample JSON object illustrating the structure of an individual offer returned by the Adspostx API, including nested beacons and creatives, as part of a larger offers array. ```JSON { "id": 4360, "title": "100% revshare for the first month!", "description": "adspostx lets you capture revenue across your user's moments delight your users with relevant offers at the right time get 100% revshare for the first month!", "click_url": "https://trk.pubtailer.com/sdk/offer/click?o_id=4360&c_id=1650&p_id=1854&sess_id=0ccc9e7f69951c889ce962975e150d69e8a76f29", "image": "https://adpx.b.cdn.net/campaigns/1650/0e4dfbe0875fd1b4190bae4dc2032320.png", "mini_text": "", "pixel": "https://trk.pubtailer.com/sdk/v2/impression/p.png?o_id=4360&c_id=1650&p_id=1854&sess_id=0ccc9e7f69951c889ce962975e150d69e8a76f29&cbuster=%7bcbuster%7d", "cta_yes": "try out adspostx!", "cta_no": "no, thanks", "useraction_cta": "", "useraction_url": "", "adv_pixel_url": "", "beacons": { "close": "https://trk.pubtailer.com/event/record/close?oid=4360&cid=1650&pid=1854&sess_id=0ccc9e7f69951c889ce962975e150d69e8a76f29", "no_thanks_click": "https://trk.pubtailer.com/event/record/no_thanks_click?oid=4360&cid=1650&pid=1854&sess_id=0ccc9e7f69951c889ce962975e150d69e8a76f29" }, "creatives": [ { "id": 1437, "url": "https://adpx.b.cdn.net/campaigns/1650/0e4dfbe0875fd1b4190bae4dc2032320.png", "height": 1530, "width": 1531, "type": "png", "is_primary": true, "aspect_ratio": 1 } ], "offerwall_enabled": true, "short_description": "capture revenue across your user's moments get 100% revshare for the first month!", "short_headline": "100% revshare for the first month!", "advertiser_name": "adspostx", "is_loyaltyboost": false, "loyaltyboost_requirements": "" } ``` -------------------------------- ### LoyaltyBoost Offer Link Example with User ID Source: https://docs.adspostx.com/api/perkswall-direct-offers Illustrates a LoyaltyBoost offer link, a specialized Perkswall direct offer that rewards users for engagement. This example includes a 'user id' parameter, which is crucial for identifying the user who will receive the reward upon conversion and is passed back to a configured postback URL. ```URL https://get.perkswall.com/offerwall?accountid=99e58babc94df55a&offer count=9&auto show=true&show logo=true&show header=true&show shadow=false&show image=true&o id=3923&user id=3203400111 ``` -------------------------------- ### Moments API Offer Response Example Source: https://docs.adspostx.com/api/anatomy-of-an-offer This JSON snippet illustrates the structure of an offer object returned by the Moments API. It details various fields such as title, description, click URL, image, pixel tracking, CTA buttons, and beacon URLs for impression and interaction tracking. The example provides a clear understanding of the data points available for integrating offers into applications. ```JSON { "data": { "offers": [ { "id": 4008, "title": "you unlocked adspostx for 90 days free!", "description": "adspostx lets you capture revenue across your user’s moments delight your users with relevant offers at the right time get 3 months free!", "click url": "https://track.adspostx.com/sdk/offer%20click?o%20id=4008&c%20id=1284&p%20id=1501&sess%20id=03a7c834ffce7ff88ff45f980577ea42a03ec904&fp=string", "image": "https://adpx.b.cdn.net/campaigns/1284/598d561b6afb86b76d3137545572a3a9.png", "mini text": "", "pixel": "https://track.adspostx.com/sdk/v2/impression/p.png?o%20id=4008&c%20id=1284&p%20id=1501&sess%20id=03a7c834ffce7ff88ff45f980577ea42a03ec904&fp=string&cbuster=%7bcbuster%7d", "cta yes": "try out adspostx!", "cta no": "no, thanks", "useraction cta": "", "useraction url": "", "adv pixel url": "", "beacons": { "close": "https://track.adspostx.com/event/record/close?oid=4008&cid=1284&pid=1501&sess%20id=03a7c834ffce7ff88ff45f980577ea42a03ec904&fp=string", "no thanks click": "https://track.adspostx.com/event/record/no%20thanks%20click?oid=4008&cid=1284&pid=1501&sess%20id=03a7c834ffce7ff88ff45f980577ea42a03ec904&fp=string" }, "creatives": [ { "id": 939, "url": "https://adpx.b.cdn.net/campaigns/1284/598d561b6afb86b76d3137545572a3a9.png", "height": 1200, "width": 1200, "type": "png", "is primary": true, "aspect ratio": 1 } ], "short description": "capture revenue across your user’s moments get 3 months free!", "short headline": "3 free months of adspostx!", "advertiser name": "adspostx" } ], "count": 3, "privacy url": "https://www.adspostx.com/end%20user%20privacy%20policy" } } ``` -------------------------------- ### Perkswall Direct Offer Tracking Link Example Source: https://docs.adspostx.com/api/perkswall-direct-offers Demonstrates the structure of a basic Perkswall tracking link used to direct users to an offer wall. This link can be obtained from the publisher dashboard by navigating to offers and selecting the three-dot menu for the desired offer. ```URL https://get.perkswall.com/offerwall?accountid=99e58babc94df55a&offer count=9&auto show=true&show logo=true&show header=true&show shadow=false&show image=true&o id=3923 ``` -------------------------------- ### Adspostx Offers Unit: Content and Text Style Override Example Source: https://docs.adspostx.com/api/customization-options Example code for customizing the offers unit content, including styles for negative and positive CTA buttons (background, color, hover, stroke), font family, font size, text color, and multi-offer unit button radius. ```APIDOC styles { // customize the offers unit content offertext { // styles for the negative cta button no { background "#fff", color "#6b7280", hover "#e5e7eb", stroke "#9ca3af" }, // styles for the positive cta button yes { background "#000000", color "#fff", hover "#0b1937", stroke "#0b1937" }, // font and colors of the offers unit body font "roboto", fontsize 14, textcolor "#000", // radius for the multi offer unit button offerwall mou button radius 5, show image true } } ``` -------------------------------- ### Example Standard Direct Offer Tracking Link Source: https://docs.adspostx.com/api/direct-offers A typical tracking link used for direct offers. When clicked, this link redirects users directly to the advertiser's website. It can be extended with additional payload information for custom tracking. ```URL https //trk pubtailer com/sdk/offer click?o id=xxxx&c id=xxx&p id=xx ``` -------------------------------- ### Direct Offer Tracking Link with Payload Source: https://docs.adspostx.com/api/marketing-direct-offers-via-push-notificationse-mail Example of a direct offer tracking link with 'user_id' and 'order_id' payload attributes appended to the URL for customized reporting and targeting. ```URL https://trk.pubtailer.com/sdk/offer/click?o_id=xxxx&c_id=xxx&p_id=xx&user_id=3a99022vv&order_id=402230000 ``` -------------------------------- ### Example Payload for Macro Usage Source: https://docs.adspostx.com/api/using-macros This JavaScript object demonstrates a sample payload structure that would be passed to the momentscience unit. The attributes within this payload, such as 'email', 'firstname', 'confirmationref', and 'amount', can be used as macros to personalize the user experience in the offer unit's header and lead-in text. ```JavaScript window.adpxuser = { email: "demo@adspostx.com", firstname: "paul", lastname: "everett", mobile: "5551237654", confirmationref: "546 231 999", amount: "$100", currency: "usd", paymenttype: "credit", zipcode: "88904", country: "us" }; ``` -------------------------------- ### Offer Catalog API Reference Source: https://docs.adspostx.com/api/offer-catalog-api Comprehensive documentation for the Offer Catalog API, detailing the GET method, base URL, required header and query parameters, and the structure of the successful JSON response, including individual offer attributes. ```APIDOC Method: GET Base URL: https://api.adspostx.com/native/v3/catalog.json ``` ```APIDOC Header Parameters: - Parameter: Content-Type Description: Required. Should be application/json. Type: string Example: application/json ``` ```APIDOC Query Parameters: - Parameter: api-key Description: Required. Your API key. Type: string Example: 4bbdefc2-b130-424d-8170-54bdcb98e64e - Parameter: offer-id Description: Optional. If provided, the response will only return data related to that specific offer. Type: string Example: 1651 - Parameter: countries Description: Optional. Specify ISO 3166-1 alpha-2 country code(s) to fetch offers related to specific countries. Use a 2-character country code (e.g., us). You can add multiple values and separate them with commas (e.g., us, in, eg). Type: string Example: us or us,in,eg - Parameter: os Description: Optional. Specify the targeted operating systems for offers. Supported values include windows, macos, android, and ios. You can add multiple values and separate them with commas (e.g., ios, android). Type: string Example: ios or ios,android - Parameter: platforms Description: Optional. Specify the targeted platforms for offers. Supported values include desktop, phone, and tablet. You can add multiple values and separate them with commas (e.g., tablet, phone). Type: string Example: desktop or tablet,phone - Parameter: browsers Description: Optional. Specify the targeted web browsers for offers. Supported values include edge, chrome, firefox, safari, and opera. You can add multiple values and separate them with commas (e.g., chrome, firefox). Type: string Example: chrome or chrome,firefox ``` ```json { "offers": [ { "id": 1651, "status": "active", "title": "free initial consultation!", "description": "adspostx lets you capture revenue across your user's moments delight your users with relevant offers at the right time start now with a free consultation ", "short headline": "free initial consultation!", "short description": "capture revenue across your user's moments start now with a free consultation ", "mini text": "", "cta": "try out adspostx!", "image": "https://adpx.b.cdn.net/campaigns/1651/63549ce925dd7372a0da4e35dfe3eeb0.png", "creatives": [ { "id": 1438, "url": "https://adpx.b.cdn.net/campaigns/1651/63549ce925dd7372a0da4e35dfe3eeb0.png", "height": 1530, "width": 1531, "type": "png", "is primary": true, "aspect ratio": 1 } ], "payout": 5, "is loyaltyboost": false, "loyaltyboost requirements": "", "click url": "https://trk.pubtailer.com/sdk/offer_click?o_id=4361&c_id=1651&p_id=1854", "targeting": { "platforms": [], "os": [], "browsers": [] } } ] } ``` ```APIDOC Response Parameters: - offers: array of offer objects Description: Each object represents the details of an offer, including its associated creatives. Attributes: - id: integer Description: Unique identifier for the offer. - status: string Description: Current status of the offer. Expected values: "active" (paused offers are not returned). - title: string Description: The title or headline of the offer. Maximum length 90 characters. - description: string Description: Detailed description of the offer. Maximum length 220 characters. - short headline: string Description: Alternative shorter text to use for the offer's headline. - short description: string Description: Alternative shorter text to use for the offer's description. - mini text: string Description: Additional short text. - cta: string Description: Call to action text. - image: string Description: URL of the primary image for the offer. - creatives: array of creative objects Description: Details about associated creative assets. Attributes: - id: integer Description: Unique identifier for the creative. - url: string Description: URL of the creative asset. - height: integer Description: Height of the creative in pixels. - width: integer Description: Width of the creative in pixels. - type: string Description: File type of the creative (e.g., "png", "jpg"). - is primary: boolean Description: Indicates if this is the primary creative. - aspect ratio: number Description: Aspect ratio of the creative. - payout: number Description: Payout amount (only available if working in an affiliate network capacity). - is loyaltyboost: boolean Description: Indicates if the offer is a loyalty boost offer. - loyaltyboost requirements: string Description: Requirements for loyalty boost offers. - click url: string Description: Tracking URL for clicks on the offer. - targeting: object Description: Object containing targeting criteria. Attributes: - platforms: array of strings Description: Targeted platforms (e.g., "desktop", "phone"). - os: array of strings Description: Targeted operating systems (e.g., "ios", "android"). - browsers: array of strings Description: Targeted web browsers (e.g., "chrome", "firefox"). ``` -------------------------------- ### Adspostx Offers Unit: Perkswall and MOU Button Style Override Example Source: https://docs.adspostx.com/api/customization-options Example code for customizing the styles of buttons within the Perkswall and Multi Offer Unit (MOU), including background, color, and hover states. ```APIDOC styles { offerwall { button { offerwall mou button background "#fff", offerwall mou button color "#6b7280", offerwall mou button hover "#e5e7eb", offerwa ``` -------------------------------- ### APIDOC: `OfferContainerView` Component Properties Source: https://docs.adspostx.com/api/react-native Documentation for the `OfferContainerView` component, detailing its input properties and callback functions. It describes how to track the current offer, handle navigation, open URLs, and fire various event beacons based on user interactions. ```APIDOC OfferContainerView Overview: - currentOffer: Keeps track of the current offer displayed by the offerView. - currentOfferIndex: Tracks the position of the currently displayed offer in an array of offers. - openUrl function: Called when the user taps on the offer image or a positive call to action (CTA). - firePixel function: To send requests to various URLs under different conditions: - When a new offer is rendered, a request is sent to the pixel URL (from `pixel`). - When the user taps on the close button, a request is sent to the `close beacon` URL (from `beacons?close`). - When the user taps on a negative CTA, a request is sent to the `beacons?no thanks click` URL. - gotoNextOffer: Responsible for handling actions when wanting to display the next offer. - gotoPreviousOffer: Responsible for handling actions when wanting to display the previous offer. ``` -------------------------------- ### Example Adspostx API Offer Response Payload Source: https://docs.adspostx.com/api/moments-api A sample JSON payload demonstrating the structure of the data returned by the Adspostx API when fetching offers. This includes details for individual offers, such as titles, descriptions, images, and tracking URLs, along with overall response metadata. ```json { "offers": [ { "id": 4586, "title": "3 free months of adspostx!", "description": "adspostx lets you capture revenue across your user's moments delight your users with relevant offers at the right time get 3 months free!", "click url": "https://trk.pubtailer.com/sdk/offer click?o id=4586&c id=1879&p id=1854&sess id=51267da82f8e1a6c2900c5c051c1648a63f8410e", "image": "https://adpx.b.cdn.net/campaigns/1879/d93fbd2662b784b655d430c9ce3789e4.png", "mini text": "", "pixel": "https://trk.pubtailer.com/sdk/v2/impression/p.png?o id=4586&c id=1879&p id=1854&sess id=51267da82f8e1a6c2900c5c051c1648a63f8410e&cbuster=%7bcbuster%7d", "cta yes": "earn 150 points", "cta no": "no, thanks", "useraction cta": "", "useraction url": "", "adv pixel url": "", "beacons": { "close": "https://trk.pubtailer.com/event/record/close?oid=4586&cid=1879&pid=1854&sess id=51267da82f8e1a6c2900c5c051c1648a63f8410e", "no thanks click": "https://trk.pubtailer.com/event/record/no thanks click?oid=4586&cid=1879&pid=1854&sess id=51267da82f8e1a6c2900c5c051c1648a63f8410e" }, "creatives": [ { "id": 1769, "url": "https://adpx.b.cdn.net/campaigns/1879/d93fbd2662b784b655d430c9ce3789e4.png", "height": 1530, "width": 1530, "type": "png", "is primary": true, "aspect ratio": 1 } ], "offerwall enabled": true, "short description": "capture revenue across your user's moments get 3 months free!", "short headline": "3 free months of adspostx!", "advertiser name": "adspostx", "is loyaltyboost": true, "loyaltyboost requirements": "user must finish integrating adspostx to qualify you must click “allow” if tracking permission is requested within the app " }, { "id": 5043, "title": "click to unlock adspostx for 90 days free!", "description": "adspostx lets you capture revenue across your user's moments delight your users with relevant offers at the right time get 3 months free!", "click url": "https://trk.pubtailer.com/sdk/offer click?o id=5043&c id=2338&p id=1854&sess id=51267da82f8e1a6c2900c5c051c1648a63f8410e", "image": "https://adpx.b.cdn.net/campaigns/1649/62a98d93af4e12a3dbbcf247172fadce.png", "mini text": "", "pixel": "https://trk.pubtailer.com/sdk/v2/impression/p.png?o id=5043&c id=2338&p id=1854&sess id=51267da82f8e1a6c2900c5c051c1648a63f8410e&cbuster=%7bcbuster%7d", "cta yes": "try out adspostx!", "cta no": "no, thanks", "useraction cta": null, "useraction url": null, "adv pixel url": "", "beacons": { "close": "https://trk.pubtailer.com/event/record/close?oid=5043&cid=2338&pid=1854&sess id=51267da82f8e1a6c2900c5c051c1648a63f8410e", "no thanks click": "https://trk.pubtailer.com/event/record/no thanks click?oid=5043&cid=2338&pid=1854&sess id=51267da82f8e1a6c2900c5c051c1648a63f8410e" }, "creatives": [ { "id": 2741, "url": "https://adpx.b.cdn.net/campaigns/1649/62a98d93af4e12a3dbbcf247172fadce.png", "height": 1530, "width": 1530, "type": "png", "is primary": true, "aspect ratio": 1 } ], "offerwall enabled": true, "short description": "capture revenue across your user's moments get 3 months free!", "short headline": "3 free months of adspostx! click to unlock", "advertiser name": "adspostx", "is loyaltyboost": false, "loyaltyboost requirements": "" } ], "count": 3, "privacy url": "https://www.adspostx.com/privacy policy" } ``` -------------------------------- ### JavaScript Payload Object Example for adspostx Source: https://docs.adspostx.com/api/google-tag-manager-gtm Example JavaScript object demonstrating the structure for `adpxpayload`, containing various user and order details for enhanced targeting and personalization. This object should be made available via JavaScript on the order confirmation page. ```JavaScript var adpxpayload = { email: 'john@doe.com', //this can be a hashed value too firstname: '', lastname: '', mobile: '', confirmationref: '', amount: '69.44', currency: 'usd', paymenttype: '', ccbin: '', zipcode: '100001', country: 'us', language: '', tags: 'cookware,loyalty', //any comma separated values can be added here subid: null } ``` -------------------------------- ### momentscience SDK Callback for Conditional Actions Source: https://docs.adspostx.com/api/customization-options This example demonstrates using the momentscience SDK callback to trigger specific actions based on different events. It shows how to call a `showmysurveys()` function when offers are closed and log user interactions for 'ad taken' and 'ad not taken' events. ```JavaScript window.adpx.init(adpxconfig, (event, payload) => { console.log('received event with payload from adspostx sdk ', event, payload); if (event === 'closed ads') { // user closed the moments offers unit; show your surveys showmysurveys(); return; } if (event === 'ad taken') { console.log('user took offer ' + payload.current + ' of ' + payload.total); return; } if (event === 'ad not taken') { console.log('user passed on offer ' + payload.current + ' of ' + payload.total); return; } }); ``` -------------------------------- ### Perkswall Direct Offer Tracking Link with Payload Source: https://docs.adspostx.com/api/marketing-direct-offers-via-push-notificationse-mail Example of a perkswall direct offer tracking link, including various display parameters and 'user_id' and 'order_id' payload attributes for personalized experiences and reporting. ```URL https://get.perkswall.com/offerwall?accountid=f0f16460-f739-4ec0-b220-b31745a78b3b&offer_count=9&auto_show=true&show_logo=true&show_header=true&show_shadow=false&show_image=true?accountid=99e58babc94df55a&o_id=3923&user_id=3a99022vv&order_id=402230000 ``` -------------------------------- ### Perkswall URL with Advanced Customization and User Identifier Source: https://docs.adspostx.com/api/perkswall This example demonstrates a Perkswall URL with multiple customization parameters, including 'adpx_fp' which is a unique user identifier. Passing 'adpx_fp' allows for optimization by surfacing relevant offers and excluding already engaged offers. ```URL https://get.perkswall.com/offerwall?accountid=99e58babc94df55a&offer_count=9&auto_show=true&show_logo=false&show_header=false&template_background=f5f5dc&btn_background=9aff02&btn_text_color=000000&btn_hover_color=b9d3ff&background=fff&adpx_fp=4023cxe ``` -------------------------------- ### Perkswall URL with Offer Count and Auto Show Customization Source: https://docs.adspostx.com/api/perkswall This example shows how to customize the Perkswall URL to limit the initial number of offers displayed and disable automatic loading of more offers. Users will need to manually trigger loading more offers. ```URL https://get.perkswall.com/offerwall?accountid=99e58babc94df55a&offer_count=9&auto_show=false ``` -------------------------------- ### React Native OfferView Component Implementation Source: https://docs.adspostx.com/api/react-native This component renders an individual offer unit, displaying its title, image, description, and interactive call-to-action buttons. It integrates with callback functions for image taps and CTA interactions. ```javascript import React, {useEffect} from 'react'; import {View, StyleSheet, Text, Image, TouchableOpacity} from 'react-native'; function OfferView({ title, imageUrl, description, clickUrl, onImageCta, positiveCta, onPositiveCta, negativeCta, onNegativeCta }) { return ( {title && {title}} {imageUrl && ( )} {description && {description}} ); } // Note: The 'styles' object for OfferView was not provided in the input text. // It is assumed to be defined elsewhere or similar to OfferContainerView's styles. ``` -------------------------------- ### Example LoyaltyBoost Direct Offer Tracking Link with User ID Source: https://docs.adspostx.com/api/direct-offers A tracking link specifically for LoyaltyBoost offers, which requires appending a user identifying attribute (e.g., 'user_id') to the payload. This ensures that the user can receive rewards within your app/website upon offer completion, with the user ID being returned in the postback. ```URL https //trk pubtailer com/sdk/offer click?o id=xxxx&c id=xxx&p id=xx&user id=3a99022vv ``` -------------------------------- ### React Native OfferView Component Props and Description Source: https://docs.adspostx.com/api/react-native This section details the properties (props) of the OfferView component, which is responsible for rendering a single offer unit. It describes each prop's purpose, type, and how it influences the offer's appearance and behavior. ```APIDOC OfferView Component Overview: Description: The OfferView component is crucial for rendering individual offer units and managing various interactions. Its primary responsibility is to render an individual offer unit. Props: title: Type: string Description: Represents the title of the offer. imageUrl: Type: string Description: Represents the URL of the offer image. description: Type: string Description: Represents the description of the offer. clickUrl: Type: string Description: Represents the URL to hit when the positive CTA is tapped or when the offer image is tapped. onImageCta: Type: function Description: A callback function triggered when the offer image is tapped. We need to fetch the click URL and then open it in an external browser, which is handled by the openUrl function. positiveCta: Type: string Description: Represents the text for the positive Call to Action (CTA), e.g., "cta yes". onPositiveCta: Type: function Description: A callback function triggered when the positive CTA is tapped. In this callback function, we open the URL stored in clickUrl in an external browser. We move the user to the next offer by invoking goToNextOffer. negativeCta: Type: string Description: Represents the text for the negative CTA, e.g., "cta no". onNegativeCta: Type: function Description: A callback function triggered when the negative CTA is tapped. In this callback function, we send a request using the URL stored in beacons?.noThanksClick. We move the user to the next offer by calling goToNextOffer. ``` -------------------------------- ### Example Postback URL with Macros (Querystring Method) Source: https://docs.adspostx.com/api/handling-postback-events This URL demonstrates how macros are used in the postback URL to directly embed relevant payload attributes. The system replaces these macros (e.g., {payout}, {user id}) with actual event data before sending the request, eliminating the need to parse a request body for these specific values. ```URL https://postback.domain.com/pb?payout={payout}×tamp={timestamp}&offer id={offer id}&advertiser name={advertiser name}&is loyaltyboost={is loyaltyboost}&confirmationref={confirmationref}&user id={user id} ``` -------------------------------- ### Fetching Offers with `fetchmomentoffers` Source: https://docs.adspostx.com/api/react-native Demonstrates how to call the `fetchmomentoffers` API within an asynchronous function to retrieve offer data. It includes error handling and processing the API response to update the application's state. The `dev` parameter can be set to '1' to enable the sandbox environment for testing. ```JavaScript await fetchmomentoffers( '', //replace with your generated api key queryparameters, payload, ); let offerarray = result.data?.data?.offers; setoffers(offerarray); } catch (error) { console.log('error in while fetchoffers ', error); setoffers(null); }; ``` -------------------------------- ### React Native OfferContainerView Component Implementation Source: https://docs.adspostx.com/api/react-native This component manages the display of multiple offers, allowing users to navigate between them and interact with call-to-action buttons. It handles offer progression, pixel firing, and opening URLs based on user actions. ```javascript import React, {useState, useEffect} from 'react'; import {View, StyleSheet, TouchableOpacity, Text} from 'react-native'; import OfferView from ' /offerview'; import {firePixel, openUrl} from ' /util'; function OfferContainerView({offers, onCloseOfferCta}) { const [currentOffer, setCurrentOffer] = useState(null); const [currentOfferIndex, setCurrentOfferIndex] = useState(0); useEffect(() => { setCurrentOffer(offers[currentOfferIndex]); console.log('[adspostxapidemo] firing pixel now'); firePixel(offers[currentOfferIndex]?.pixel); }, [currentOfferIndex]); const goToNextOffer = shouldClose => { console.log('[adspostxapidemo] go to next offer tapped'); var currentIndex = currentOfferIndex; if (currentIndex === offers.length - 1) { if (!shouldClose) { return; } onCloseOfferCta(currentOfferIndex, shouldClose); return; } currentIndex += 1; setCurrentOfferIndex(currentIndex); }; const goToPreviousOffer = () => { var currentIndex = currentOfferIndex; if (currentIndex === 0) { return; } console.log('[adspostxapidemo] go to previous offer tapped'); currentIndex -= 1; setCurrentOfferIndex(currentIndex); }; return ( { onCloseOfferCta(currentOfferIndex, true); }} style={{flexDirection: 'row-reverse', padding: 8}}> close {currentOffer && ( { openUrl(currentOffer?.click_url); }} positiveCta={currentOffer.cta_yes} onPositiveCta={() => { console.log('[adspostxapidemo] positive cta clicked'); console.log('[adspostxapidemo] opening a link url'); openUrl(currentOffer?.click_url); goToNextOffer(true); }} negativeCta={currentOffer.cta_no} onNegativeCta={() => { console.log('[adspostxapidemo] negative cta clicked'); console.log( '[adspostxapidemo] fire no thanks beacon when negative cta tapped ', ); firePixel(currentOffer?.beacons?.no_thanks_click); goToNextOffer(true); }} /> )} {'<'} { goToNextOffer(false); }} style={styles.navigationButton}> {'>'} ); } const styles = StyleSheet.create({ container: { justifyContent: 'flex-start', flexDirection: 'column', borderColor: 'black', borderRadius: 8, borderWidth: 1, margin: 8 }, bottomToolbar: { height: 44, width: '100%', backgroundColor: 'black', alignItems: 'center', justifyContent: 'space-evenly', flexDirection: 'row' }, navigationButton: { backgroundColor: 'grey', padding: 8, paddingStart: 16, paddingEnd: 16 } }); export default OfferContainerView; ``` -------------------------------- ### Track Adspostx Offer Performance with Subid and Placement Source: https://docs.adspostx.com/api/passing-payload-values Demonstrates how to include 'subid' and 'placement' attributes to track the source and segment traffic for Adspostx offers. Examples are provided for JS SDK, Moments/Perkswall API (JSON payload), and direct offer links, showing how to pass these values for better performance analysis. ```JavaScript window.adpxuser = { // other payload attributes "subid": "moments offer unit", "placement": "post transaction" }; ``` ```JSON { // other payload attributes "subid": "moments offer unit", "placement": "post transaction" } ``` ```URL https://trk.pubtailer.com/sdk/offerclick?o_id=xxxx&c_id=xxx&p_id=xx&user_id=3a99022vv&subid=moments%20offer%20unit&placement=post%20transaction ``` ```URL https://get.perkswall.com/offerwall?accountid=f0f16460f7394ec0b220b31745a78b3b&o_id=3923&subid=moments%20offer%20unit&placement=post%20transaction ``` -------------------------------- ### Wrapper Function to Fetch Adspostx Moment Offers Source: https://docs.adspostx.com/api/react-native This asynchronous JavaScript function acts as a wrapper for the Adspostx Moments API, utilizing 'axios' to make POST requests. It handles constructing the API URL with relevant query parameters, defining necessary headers including the user agent, and managing payload data for fetching offers. ```JavaScript import axios from 'axios'; import {firepixel, getuseragent, openurl} from ' /util'; import { useState } from 'react'; const [offers, setoffers] = useState(null); // function to fetch moment offers from the api const fetchmomentoffers = async (apikey, queryparameters, payload) => { try { let useragent = payload?.ua ?? (await getuseragent()); // define headers for the api request const headers = { 'content-type': 'application/json', 'accept': 'application/json', // user agent value can be obtained from the // "react native device info" package 'user-agent': useragent, }; const allqueryparameters = { 'api-key': apikey, ...(queryparameters || {}), }; // remove undefined values from allparams if (queryparameters) { Object.keys(allqueryparameters).forEach( key => allqueryparameters[key] === undefined && delete allqueryparameters[key] ); } // remove undefined values from payload if (payload) { Object.keys(payload).forEach( key => payload[key] === undefined && delete payload[key] ); } // generate the query string const querystring = Object.keys(allqueryparameters).map( key => `${encodeURIComponent(key)}=${encodeURIComponent( allqueryparameters[key], )}`, ).join('&'); // construct the api url const apiurl = `http://api.adspostx.com/native/v2/offers.json${querystring ? `?${querystring}` : ''}`; // make a post request to the api const response = await axios.post(apiurl, payload, {headers}); return response; } catch (error) { throw error; } }; ``` -------------------------------- ### React Native UI State and OfferContainerView Integration Source: https://docs.adspostx.com/api/react-native Demonstrates how to manage the UI state for offers using React's `useState` hook and integrate the `OfferContainerView` component. It includes a callback function `oncloseoffercta` that handles user actions like closing the offer container or tapping a negative CTA, conditionally firing a pixel based on the action. ```JavaScript const [offers, setoffers] = useState(null); const [isofferclosed, setofferclosed] = useState(false); {!isofferclosed && offers && offers.length > 0 && ( { console.log('[adspostxapidemo] close button tapped'); if (shouldfirepixel) { firepixel(offers[currentIndex]?.beacons?.close); } setofferclosed(true); }} /> )} ``` -------------------------------- ### JavaScript `firepixel` Function Implementation Source: https://docs.adspostx.com/api/react-native Implements the `firepixel` function, which sends GET requests to specified URLs using Axios. This function is crucial for tracking various user interactions, such as when a new offer is displayed, a negative call to action is tapped, or the close button is pressed. ```JavaScript import axios from 'axios'; import { Linking } from 'react-native'; import DeviceInfo from 'react-native-device-info'; export const firepixel = url => { if (url) { console.log('[adspostxapidemo] inside fire pixel'); axios.get(url) .then(response => { console.log('[adspostxapidemo] fire pixel success ', response.data); }) .catch(error => { console.error('fire pixel error ', error); }); } }; ``` -------------------------------- ### JavaScript SDK `init` Function Parameters Source: https://docs.adspostx.com/api/js-sdk-for-websites This section details the configuration options available for the `window.adpxconfig` object, which is passed to the `adpx.init()` function. It describes each parameter's type, whether it's required or optional, its default value, and its purpose. ```APIDOC window.adpxconfig object: accountid: Type: string Description: Your unique account id, use your sdk id. Required: true autoload: Type: boolean Description: 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. Optional: true Default: true autoshow: Type: boolean Description: 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. Optional: true Default: true dev: Type: boolean Description: 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. Optional: true Default: false settings: Type: object Description: It can be used to override some dashboard settings and to configure the presentation of the moments unit. Optional: true styles: Type: object Description: It can be used to apply custom styling at runtime. Optional: true ``` -------------------------------- ### AdsPostX API Error Response Examples Source: https://docs.adspostx.com/api/errors Examples of standard error responses returned by the AdsPostX (now MomentScience) API for failed requests. ```JSON { "statuscode": 400, "message": "invalid request parameters" } ``` ```JSON { "data": {}, "status": "fail", "message": "no results found" } ``` -------------------------------- ### Initialize momentscience SDK with Basic Callback Source: https://docs.adspostx.com/api/customization-options This snippet demonstrates how to pass a simple callback function as the second parameter to the `init` function of the momentscience SDK. The callback logs events and their payloads received from the SDK, allowing for basic event monitoring. ```JavaScript window.adpx.init(adpxconfig, (event, payload) => { console.log('received event with payload from adspostx sdk ', event, payload); }); ```