Script-Tag Integration
This installation type is recommended if your are using no JavaScript loaders or no JavaScript at all.
It loads the FeedAd SDK into your website without the need for any loaders or module bundlers.
It will expose a global feedad
object which can be used to request and configure ads.
There are two ways how to load the SDK via Script-Tag:
- A loader script (recommended) that will load the latest and smallest version of the SDK for the user's browser.
- Direct reference to a specific version or the latest version of the SDK.
Loader Script
When to use it
- You do not bundle the SDK within the source code of your website.
- You do not apply ES6 polyfills to the JavaScript runtime of your website.
- You are integrating the FeedAd SDK into a website whose JavaScript language features you are uncertain of.
What it does
- It checks if the browser supports the FeedAd SDK.
- If the browser supports the SDK but is missing some JavaScript language features, it loads polyfills prior to loading the SDK.
- It loads the most recent version of the SDK.
- It provides a callback that is compatible with all browsers, regardless if the FeedAd SDK is supported.
- It loads asynchronous, with minimal impact on the load time of your website.
How to use it
Include the loader script within your website:
<script async type="text/javascript" src="https://web.feedad.com/sdk/feedad-async.js"></script> <script type="text/javascript"> window.feedad = window.feedad || {cmd: []}; feedad.cmd = feedad.cmd || []; // optional: set error callback that is called when the SDK cannot be loaded feedad.onError = function (error) {}; // initialize the SDK feedad.cmd.push(function () { feedad.sdk.init("your-client-token"); }); // request a FeedAd feedad.cmd.push(function () { feedad.sdk.requestAd("your-placement-id") //... }); </script>
Important Differences with the Loader-Script
- All SDK method calls should be pushed to the
feedad.cmd
array, to assure that they get executed once the SDK is ready. - Every method that is documented as
feedad.<method>
needs to be called onfeedad.sdk.<method>
. For example:feedad.init(clientToken)
→feedad.sdk.init(clientToken)
feedad.requestAd(placementId, options)
→feedad.sdk.requestAd(placementId, options)
Continue reading the documentation on how to request an ad.
Direct Reference
The SDK is available in 3 build variants:
https://web.feedad.com/sdk/feedad-sdk-lib.[version].js
- ES5 build of the SDK without polyfills (UMD module).https://web.feedad.com/sdk/feedad-sdk-es6.[version].js
- ES6 build of the SDK without polyfills (CommonJS module).https://web.feedad.com/sdk/feedad-sdk-full.[version].js
- ES5 build of the SDK including polyfills (UMD module).https://web.feedad.com/sdk/feedad-latest.js
- Alias for the latestfull
version.
You will find the latest version of the SDK at https://web.feedad.com/sdk/latest.txt.
If you do not choose the full
or latest
variant you'll have to make sure, that the necessary polyfills are installed in your runtime:
If you do not choose the full
or latest
variant, you'll have to make sure that the necessary polyfills are installed in your runtime:
Once you've chosen a build, just add it to your website:
<script type="text/javascript" src="https://web.feedad.com/sdk/feedad-latest.js" defer></script> <script type="text/javascript" defer> // a global 'feedad' object will be available </script>
Request an Ad
Read the guide for your desired ad type to learn how to request an ad:
- Feed Ad - 'Banner-like' ad to integrate into one or multiple placements on your website.
- Standalone Ad - Pre-Roll ad to integrate before giving access to (video) content