Developers API
Options
For set options - insert code to page head.
Page tags
<script>
var adsinserter = adsinserter || {};
adsinserter.tags = [ 'test', 'style', 'page-2' ];
</script>
Set tags for current page. Use for filtering units by tags.
Methods
render()
Render all not rendered placements.
<script>
adsinserter.render();
</script>
on(eventName, fn)
Add event listener. Example:
<script>
adsinserter.on('unit.rendered', function(unitObj) {
console.log('Unit rendered:', unitObj.id);
});
</script>
Events
placement.render
Placement rendering started.
<script>
adsinserter.on('placement.render', function(placementObj) {
// placementObj.id - placement ID, number
// placementObj.element - placement element, HTMLElement
console.log('Placement render:', placementObj.id);
});
</script>
unit.added
Unit element added to placement.
<script>
adsinserter.on('unit.added', function(unitObj) {
// unitObj.id - unit ID, number
// unitObj.element - unit element, HTMLElement
console.log('Unit added:', unit.id);
});
</script>
unit.rendered
Unit code inserted and executed.
<script>
adsinserter.on('unit.rendered', function(unitObj) {
// unitObj.id - unit ID, number
// unitObj.element - unit element, HTMLElement
console.log('Unit rendered:', unit.id);
});
</script>
unit.skipped
Unit skipped by filter or rotation.
<script>
adsinserter.on('unit.skipped', function(unitObj) {
// unitObj.id - unit ID, number
// unitObj.element - unit element, HTMLElement
console.log('Unit skipped:', unit.id);
});
</script>
unit.reseted
Unit reseted (repainter) after change in AdsInserter.
<script>
adsinserter.on('unit.reseted', function(unitObj) {
// unitObj.id - unit ID, number
// unitObj.element - unit element, HTMLElement
console.log('Unit reseted:', unit.id);
});
</script>
Other
Callback after AdsInserter loaded and inited (Async init)
<script>
(adsinserter = adsinserter || {}).onload = function() {
console.log('AdsInserter loaded');
}
</script>