{"__v":9,"_id":"575ff4e6c0bca70e00afbfa1","category":{"__v":14,"_id":"55e89569cdbb8a350096df9c","pages":["55e896ac4535442d00ccacf3","55e8b205f0f1850d00d24a59","55e8b243720fde1700659a0e","55e8b4258c0c601700f978e0","55e8b5537cdf7119002d2e3a","55e8b5737cdf7119002d2e3c","55e8b5863fef5017000dbd9f","55e8b59ef0f1850d00d24a63","563b50349e3f2225009fd296","5640d891d4b2e00d00bb3d48","564cfd4e2248461700bd4021","5660e89689e82f0d008f6832","5668d3428ff3da0d0079092f","56abb944f25f160d00e17f40"],"project":"5429beef1163360800ed31fa","version":"5429beef1163360800ed31fd","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-09-03T18:46:01.692Z","from_sync":false,"order":1,"slug":"sdk-integrations","title":"Integrating for Web"},"parentDoc":null,"project":"5429beef1163360800ed31fa","user":"563b4a20dfa1282b000dd262","version":{"__v":21,"_id":"5429beef1163360800ed31fd","project":"5429beef1163360800ed31fa","createdAt":"2014-09-29T20:19:59.904Z","releaseDate":"2014-09-29T20:19:59.904Z","categories":["5429beef1163360800ed31fe","55e74e1f5d36b32b002563fa","55e7500a73169617001f2e86","55e76b8196131b2f00bf4b72","55e89569cdbb8a350096df9c","55f8935eb089b71700a8364e","55f8a67d3bb4bb0d0022d093","55f9dbefc7ef770d00d9bf6d","5601c21a22ecf60d002b27b3","5601c21ff12aee0d001bb06e","5601c2256c7b610d00280db5","5601c22c22ecf60d002b27b4","5603738d0c78b00d0039af47","5626f70bfcbbc621004ebf52","566f7a1ae144ab0d00e9732f","566f85ca7820960d00c3b93d","56708ce43a32d20d00c45cbf","56708d436995210d003aad8e","5736471abe10a9200030732c","57a82c7aff9bd30e00a6f1c1","591b8500e3992319007190f4"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":["581e20cc0102b50f008d583e"],"next":{"pages":[],"description":""},"createdAt":"2016-06-14T12:13:26.943Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[]},"method":"get","results":{"codes":[]},"settings":"57762cbbd44a3e0e00329d68","auth":"required","params":[],"url":""},"isReference":true,"order":10,"body":"You can capture audience segments by using the JavaScript above. You need to invoke the javascript from your website when you want to add a user to an existing audience segment.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<!-- Begin ADSNATIVE Code -->\\n<script type = \\\"text/javascript\\\" >\\n    var ANSegmentPixel = function(e) {\\n        if (undefined != typeof e && e) {\\n            var d = \\\"https://pdb.adsnative.com/seg.gif?segment_token=\\\" + e;\\n            document.write('<img src=\\\"' + d + '\\\" width=\\\"1\\\" height=\\\"1\\\" border=\\\"0\\\"/>');\\n        }\\n    };\\n\\t  ANSegmentPixel('5MGHWWE3');\\n</script>\\n<noscript>\\n    <img src = \\\"https://pdb.adsnative.com/seg.gif?segment_token=DLQUBB4X\\\" width = \\\"1\\\" height = \\\"1\\\" border = \\\"0\\\" />\\n</noscript>\\n<!-- End ADSNATIVE Code —>\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nIn the script above, '5MGHWWE3' is the segment token of the audience segment you want to add user to. You need to replace it with the token of your segment (as listed on Console).\n\nIf you want to capture audience segments through server side API instead of JavaScript, please refer to this [documentation](http://dev.adsnative.com/v1.0/docs/audience-segments-api).\n\nFor instructions on creating and managing audience segments on Console, please refer to this [documentation](http://dev.adsnative.com/v1.0/docs/profile-db).","excerpt":"JavaScript for publishers to build Audience Segments (ProfileDB) using AdsNative platform","slug":"audience-segments-js","type":"endpoint","title":"Audience Segments JS"}

getAudience Segments JS

JavaScript for publishers to build Audience Segments (ProfileDB) using AdsNative platform

You can capture audience segments by using the JavaScript above. You need to invoke the javascript from your website when you want to add a user to an existing audience segment. [block:code] { "codes": [ { "code": "<!-- Begin ADSNATIVE Code -->\n<script type = \"text/javascript\" >\n var ANSegmentPixel = function(e) {\n if (undefined != typeof e && e) {\n var d = \"https://pdb.adsnative.com/seg.gif?segment_token=\" + e;\n document.write('<img src=\"' + d + '\" width=\"1\" height=\"1\" border=\"0\"/>');\n }\n };\n\t ANSegmentPixel('5MGHWWE3');\n</script>\n<noscript>\n <img src = \"https://pdb.adsnative.com/seg.gif?segment_token=DLQUBB4X\" width = \"1\" height = \"1\" border = \"0\" />\n</noscript>\n<!-- End ADSNATIVE Code —>", "language": "javascript" } ] } [/block] In the script above, '5MGHWWE3' is the segment token of the audience segment you want to add user to. You need to replace it with the token of your segment (as listed on Console). If you want to capture audience segments through server side API instead of JavaScript, please refer to this [documentation](http://dev.adsnative.com/v1.0/docs/audience-segments-api). For instructions on creating and managing audience segments on Console, please refer to this [documentation](http://dev.adsnative.com/v1.0/docs/profile-db).