Use the following template to setup OneSignal postbacks to Voluum.

This way you can use Advertizer for example to pay for subscribers on CPA.

Using this example you will also be able segment by Device, Brand, Model, OS, ISP, Carrier and Source so you can target this later in OneSignal.

[php] <link rel="manifest" href="/manifest.json" /> <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async=""></script> <script> function getURLParameter(name) { return decodeURI( (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] || '' ); } var OneSignal = window.OneSignal || []; OneSignal.push(function() { OneSignal.init({ appId: "YOUR ONESIGNAL APP ID HERE", }); }); OneSignal.push(function() { var device = getAllUrlParams().device.replace(/%20/g, " "); var brand = getAllUrlParams().brand.replace(/%20/g, " "); var model = getAllUrlParams().model.replace(/%20/g, " "); var os = getAllUrlParams().os.replace(/%20/g, " "); var isp = getAllUrlParams().isp.replace(/%20/g, " "); var carrier = getAllUrlParams().carrier.replace(/%20/g, " "); var sourcename = getAllUrlParams().sourcename.replace(/%20/g, " "); var clickid = getAllUrlParams().clickid; OneSignal.on("notificationPermissionChange", function(permissionChange) { var currentPermission = permissionChange.to; }); OneSignal.on("subscriptionChange", function (isSubscribed) { console.log("The user's subscription status has change, isSubscribed:", isSubscribed); OneSignal.getUserId( function(userId) { console.log("OneSignal User ID:", userId); if (isSubscribed) { OneSignal.sendTag("device_key", device); OneSignal.sendTag("brand_key", brand); OneSignal.sendTag("os_key", os); OneSignal.sendTag("sourcename_key", sourcename); OneSignal.sendTag("isp_key", isp); OneSignal.sendTag("carrier_key", carrier); var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == XMLHttpRequest.DONE) { } } xhr.open("GET", "https://your-postback-domain.com/postback?cid="+getURLParameter("cid"), true); xhr.send(null); setTimeout(function(){location.href="https://success-redirect-campaign.com/e3944754391-da9bfc8352604"; },1500); } }); }); }); function getAllUrlParams(url) { var queryString = url ? url.split('?')[1] : window.location.search.slice(1); var obj = {}; if (queryString) { queryString = queryString.split('#')[0]; var arr = queryString.split('&'); for (var i=0; i<arr.length; i++) { var a = arr[i].split('='); var paramNum = undefined; var paramName = a[0].replace(/\[\d*\]/, function(v) { paramNum = v.slice(1,-1); return ''; }); var paramValue = typeof(a[1])==='undefined' ? true : a[1]; paramName = paramName.toLowerCase(); if (obj[paramName]) { if (typeof obj[paramName] === 'string') { obj[paramName] = [obj[paramName]]; } if (typeof paramNum === 'undefined') { obj[paramName].push(paramValue); } else { obj[paramName][paramNum] = paramValue; } } else { obj[paramName] = paramValue; } } } return obj; } </script> [/php]

You will have to change the Voluum Postback domain on line 47:
xhr.open("GET", "https://your-postback-domain.com/postback?cid="+getURLParameter("cid"), true);


Pathaksa Tongpitak About the Author

Pathaksa Tongpitak

Pathaksa is an accomplished super affiliate and full-stack PHP developer with more than 15 years in the digital space and the founder of AffiliateWeapons.com. Throughout his career, he's empowered countless entrepreneurs and affiliates to optimize their online ventures through innovative solutions and strategic guidance. Beyond curating premium marketing deals, he dedicates himself to sharing industry insights while maintaining an extensive database of 6304+ verified promotions and discounts.