SDK DocumentationRecipesAnnouncementsSupport Forum
AndroidiOSAnnouncementsSupport Forum

Widget via Native


Have you gone through the instructions of Getting started?

  • Make sure to complete the SDK installation before performing the procedures in the following article
  • Widget via Native supports Android API 14 and above


See our code examples!

On our Github repository, you may find numerousย code examplesย demonstrating the usage of our features.


Stuck? Confused? Use our Support Forum!

If you need quick help in integrating Taboola SDK into your help, you can use our support forum. The forum is monitored continuously by Taboola Support and will respond within 24 business hours.

Step 1: Update the AndroidManifest.xml

In addition to the SDK installation update, add the following tag to any activity intended to show the TaboolaWidget. It is important to include the following attribute to avoid reloading the Taboola recommendations multiple times unnecessarily:

<!-- Add to your activity section on the AndroidManifest.xml -->
<activity android:name=".MainActivity" 

Step 2: Initialize Taboola

Create a PublisherInfo object and init Taboola

PublisherInfo publisherInfo = new PublisherInfo(<MyPublisherId>);
  • publisherId - Your publisher ID as provided to you by Taboola account manager

Step 3: Displaying the TaboolaWidget

There are two options of adding TaboolaWidget to your layout. One is using the layout XML file and one is dynamically creating the object in the code.

Layout XML

In your Activityor Fragment layout xml file:

  1. Include the Taboola XML declaration and include the TaboolaWidget tag
  2. Configure the TaboolaWidget properties.
    In the XML below, replace the following attribute values with those provided by your Taboola account manager: publisher, mode, placement, url, page_type, and `target_type.
<!-- Android SDK 2.2.2 and below: -->

<!-- Android SDK 2.2.3 and above: -->
  • taboola:tb_mode - Your mode parameter as provided by your Taboola account manager
  • taboola:tb_page_type - Your page type parameter as provided by your Taboola account manager
  • taboola:tb_placement - Your placement parameter as provided by your Taboola account manager
  • taboola:tb_publisher - Your publisher parameter as provided by your Taboola account manager
  • taboola:tb_target_type - Your target type parameter as provided by your Taboola account manager
  • taboola:tb_url - The full URL of public web page which reflects the current screens content. If the view is used on other screens, please change this value using the setPageUrl function as described below in "Dynamically via the code" section



Taboola Widget will automatically resize itself to show its content. When defining the Widget via XML please set the height to wrap_content. The Widget will resize itself when it loads.

  1. Import and init the TaboolaWidget.
// Import TaboolaWidget

// Declare an class member instance TaboolaWidget
private TaboolaWidget taboolaWidget;



  • The TaboolaWidget object is used to define both the Feed and the Widget. The integration is different.
  • TaboolaWidget subclass WebView behaves just like any other standard Android view
  1. In your Activity's OnCreate() or Fragment's OnCreateView(), find the TaboolaWidget defined in the XML.
taboolaWidget = (TaboolaWidget) <Activity>.findViewById(;

Dynamicly via the code

You can create TaboolaWidget in your code as early as possible in the app lifecycle.

  • Your activity's onCreate() method
  • Your fragmant's onCreateView() method
//Import TaboolaWidget

//Declare an class member instance TaboolaWidget
private TaboolaWidget taboolaWidget;

//In your Activity's OnCreate() or Fragment's OnCreateView(), create a new TaboolaWidget instance
taboolaWidget = new TaboolaWidget(<Context>);

//Assign LayoutParams to TaboolaWidget
taboolaWidget.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));

//Add TaboolaWidget to your layout (This example assumes your parent layout is a FrameLayout with an arbitrary id parent_layout)
FrameLayout frameLayout = (FrameLayout) <Activity>.findViewById(;

//Set the following parameters in your TaboolaWidget instance, before calling fetchContent()
	//Optional: sets an internal ID for the current page

//fetch the content
  • setPublisher - Your publisher id parameter as provided by your Taboola account manager
  • setMode - Your mode parameter as provided by your Taboola account manager
  • setPlacement - Your placement parameter as provided by your Taboola account manager
  • setPageUrl - The full URL of a public web page which reflects the current screen's content
  • setPageType - Your page type parameter as provided by your Taboola account manager
  • setTargetType - Your target type parameter as provided by your Taboola account manager
  • setPageId (optional) - An internal identification for the current screen's content. Pass this along the page URL to set the item ID as your internal ID


Missing Parameter Values

If you do not yet have production parameters, contact your Taboola account manager. For testing parameters see further down the page.

Step 4: Fetch content

  1. To show TaboolaWidget recommendations, request fetchContent().
  2. Adjust the Widget height according to the next step


Important Note

  • To maintain good UX - please fetch content as soon as the screen loads and not when the user reaches the Taboola area on the screen
  • When working with ViewPager, Please fetch the widget content only when the next page is visible to the user. You can do it by using the ViewPager.OnPageChangeListener listener

Step 5: Adjust the Widget height

As described in step 2, TaboolaWidget adjusts it height automatically. The height of the widget may dynamically change according to the different UI mode that is loaded in Taboola Backstage. When the widget resizes itself it will also resize the cell the widget is in.

In order to adjust the app layout (the cell that contains the widget) to these changes you can call the taboolaViewResizeHandler method of the TaboolaEventListener.

If wish to adjust the size of Taboola Widget manually, you can do so by setting autoResizeHeight to false and set fixed height for TaboolaWidget manually. Please keep in mind that setting a fixed height for widget will require a code change in case the widget layout changes in the future. We recommend to use dynamic height.

taboolaWidget.setTaboolaEventListener(new TaboolaEventListener() {
 public boolean taboolaViewItemClickHandler(String url, boolean isOrganic) {
  return false; // See step 5 "Intercepting Recommendation Clicks"

 public void taboolaViewResizeHandler(TaboolaWidget widget, int height) {
   //Set the cell height according to the final height value...



In order to allow Taboola increase/decrease the widget size, please keep the Widget size definition as dynamic. Using fixed height can cause native code changes on your app size to reflect the changes

Step 6: Additional Integration Information (Optional)

This section describes some optional points in the integration.

Catching global notifications (broadcasts) from TaboolaWidget

Taboola fires app level broadcasts to notify registered objects within the app about certain events.

To catch those notifications, you can use the class `

  1. Create a new GlobalNotificationReceiver object in your Activity/Fragment
  2. In onCreate() register GloablNotificationReceiver using the following code:
public void onCreate(@Nullable Bundle savedInstanceState) {
  1. Implement the interface OnGlobalNotificationsListener. you can use the following methods:
public void taboolaDidReceiveAd(TaboolaWidget widget);
public void taboolaViewResized(TaboolaWidget widget, int height);
public void taboolaItemDidClick(TaboolaWidget widget);
public void taboolaDidFailAd(TaboolaWidget widget, String reason);
  1. Starting from Android SDK 2.5.0 and above we added two tools regarding the taboolaDidFailAd method;

detailedErrorCodes - a flag that activates an explained error reasons strings

  • When set to true - the following strings are in use: NO_ITEMS (no fill by Taboola), WRONG_PARAMS (wrong "tb_mode" was used), RESPONSE_ERROR, TIMEOUT (connectivity issue), UNKNOWN_ERROR, and INTERNAL_1
  • When set to false (default) - unorganized and unmaintained error reasons strings are in use

autoCollapseOnError - a flag that can add the ability to handle the collapsing/hiding of TaboolaWidget in case of an error.

  • When set to false - Only the taboolaDidFailAd method will fire and the publisher handles the collapsing (recommended)
  • When set to true (default) - Taboola will handle the collapse in case of an error and the taboolaDidFailAd is not fired
//when autoCollapseOnError=false, the publisher is handling the collapse of
//Taboola in case of an error
//when detailedErrorCodes=true an explained error reasons strings are in use
HashMap<String, String> extraProperties = new HashMap<>();
extraProperties.put("autoCollapseOnError", "false");
extraProperties.put("detailedErrorCodes", "true");
  1. Make sure you unregister the GloablNotificationReceiver on onDestroy() using this code:
public void onDestroy() {

You can see a code example of the GlobalNotificationReceiver here

Intercepting Organic Recommendation Clicks

The SDK enables app developers to change the default behavior when a user clicks on an organic item. For example, you might want to create a click-through or to override the default way of opening the organic recommended article which is opening the click using Chrome custom tab.

To intercept organic clicks, implement the interface

//TaboolaEventListener include the methods:
public boolean taboolaViewItemClickHandler(String url, boolean isOrganic);
public void taboolaViewResizeHandler(TaboolaWidget widget, int height);

//Example implementation: In the same Activity/Fragment as TaboolaWidget instance:
TaboolaEventListener taboolaEventListener = new TaboolaEventListener() {
public boolean taboolaViewItemClickHandler(String url, boolean isOrganic) {
   return false;

public void taboolaViewResizeHandler(TaboolaWidget taboolaWidget, int height) {

//Connect the event listener to your TaboolaWidget instance.

Event: taboolaViewItemClickHandler
boolean taboolaViewItemClickHandler(String url, boolean isOrganic). This method is called every time a user clicks a Taboola Recommendation, immediately before it is handled by the operating system to resolve the relevant action. The return value of this method enables you to control further system behavior (after your own code executes).
URL - the original click URL
isOrganic - indicates whether the item clicked was organic Taboola Recommendation content or not. Best practice is to suppress the default behavior for organic items and, instead, open the relevant screen in your app which shows that piece of content.
Return value:

  • Returning false - the click's default behavior is aborted. The app should display the Taboola Recommendation content on its own (for example, using an in-app browser).
  • Returning true - the click is a standard one and is sent to the Android OS for default behavior.
public boolean taboolaViewItemClickHandler(String url, boolean isOrganic) {
    if (isOragnic){
        return false;
    return true;

Using more than one Taboola asset on the same screen

It is possible to add more than one Taboola asset on the same screen. For example, placing two Taboola widgets on a feed style screen. When doing so it is important to avoid duplicate items on each asset

To do so, please make sure you do the following:

  1. Set the same viewId value for each taboolaWidget object before fetching content. The viewId value must be a string of digits. We recommend using the current epoch timestamp. In any case, the viewId value can not exceed 19 digits.
  2. Fetch the content for the second asset only after a response is received for the first asset. Please use the GlobalNotificationReceiver to listen to render is done events
//Sets view ID value for the first item and fetch content

//Sets view ID value for the second item

//Fetch content for the 2nd Taboola asset only after the completion of the 1st item
public void taboolaDidReceiveAd(TaboolaWidget taboolaWidget) {
 Log.d(TAG, "taboolaDidReceiveAd() called with: taboolaWidget = [" + taboolaWidget + "]");

Step 7: Test the integration

To test the integration, you can use our Android SDK Integration Verifier special mode

In addition to that, you can use the following parameters for testing and development. Sponsored items are flagged with an SC: prefix in the title; organic items are flagged with an OC: prefix in the title.

Testing parametersMid article widgetBelow article widget
placement"Mid Article""Below Article"

Step 8: Code Examples

You can find the entire code examples on our Github repository

For your convenience we listed some quick links for noticable examples:

Step 9: Submit APK for QA

When you have finished the integration, contact your account manager and send a debuggable version of your Android project. Set the project to allow SSL proxying.

You're done!

Integration Support

Should you have any problems integrating the product, log a ticket with us by emailing your account manager. For non official SLA support you can also check our discussion forum