How to implement Outbrain’s JS code?

Getting ready for Outbrain’s recommendations is simple and straightforward.

Outbrain’s JS code is the most used type of our widget, and our code snippet consists of two lines of code.

Implementing the Outbrain JS code involves two simple steps:

  1. Place your code snippet in the area of the <body> of the page where you want our widget to appear. If you have multiple widgets, you will have to place the corresponding number of snippets each in their respective position.

Your Account Manager will provide you with the proper WIDGET_ID values for each of your placements.

  1. Pass one dynamic parameter (the Permalink) into the data-src variable (highlighted above). This value should be the URL of the page on which the widget is loading. We recommend using the canonical or og:url of the page, as long as one of these is consistently used across the site. So that Outbrain won’t crawl URLs with extraneous parameters or secondary pages of slideshows. If this field is not available on the script that was provided to you, please ignore this step as it means we are able to automatically recognize the permalink.

For more details, please refer to the detailed implementation guide.

Our widget code can be implemented in a test environment, or directly in production. 

If the widget is implemented in a test environment, it is ideal if you can pass production URLs into the data-src variable in testing, either dynamically or hard-coded. This prevents us from indexing your test domains. This step is not a requirement for the widgets to work, but streamlines the process and ensures a faster styling turnaround.

If the widget is implemented in the production environment, we can hide the widget initially, and push to production when desired. Outbrain has our own draft environment, accessible by adding a parameter to the page URL, where the widget will be visible. We can use this environment to finalize styling and guarantee everything is functioning correctly.

Please remember to update your Ads.txt file to validate Outbrain as an authorized digital seller of your inventory.

We support alternative implementations like Single Page Applications, Infinite Scroll or iFrames- they just require an additional code snippet. Please refer to the detailed implementation guide above, or reach out to your Account Manager.