Monetization Framework
Quickstart Templates
The majority of use cases are covered by our quickstart templates and they allow you to get up and running very quickly.
Before you integrate ads on your website you will want to make sure that you
replace the demo zonekey
in these examples with your own from your
BuySellAds account.
1. Load monetization.js
Monetization.js is the base framework with everything you will need. Simply copy+paste the JavaScript code below into the <head>
tag of your website:
JavaScript
<script
src="//m.servedby-buysellads.com/monetization.js"
type="text/javascript"
></script>
2. Create a target element where the ad will get injected
Best practice is to use a unique id for this element like so:
HTML
<div id="native-ad"></div>
Not every template requires a target element. Templates like FancyBar and FlexBar have a predefined element ID, so you don’t have to include it in the HTML body.
3. Initiate the ad script with your own zonekey
:
HTML
<script>
(function(){
if(typeof _bsa !== 'undefined' && _bsa) {
_bsa.init('default', 'CVADC53U', 'placement:demo', {
target: '#native-ad',
align: 'horizontal'
});
}
})();
</script>
Once the script is ready and the target element is available, you may call the script by running _bsa.init
(as shown in the code above). The init function accepts these variables:
Variable | Description |
---|---|
template | The template you’re using. Some of the templates you may choose are default, flexbar, fancybar, and custom. |
zonekey | The zone key you can get when you’re accepted in the Native Performance Network. For example, the demo zone key is CVADC53U . |
placement | The placement name. Usually, you’ll use your domain name without any special characters. For example, for buysellads.com you’ll use buyselladscom as the placement name. |
It also accepts options to customize the ad behavior. Here are some options you can pass:
Options | Description | Default Value |
---|---|---|
target | Pass the ID of the element, so the script knows where to inject the ad. | #default_demo |
disable_css | This allows you to disable the default CSS. | false |
align | Options are horizontal or vertical | horizontal |
That's it - those are the basics for getting started with the BuySellAds Monetization Framework. From here you might want to explore the various templates or look into building your own custom templates.