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 constantly monitored by Taboola Support and will respond within 24 business hours.
## Step 1: Init Taboola
Create a `
PublisherInfo` object and init Taboola
publisherId` - Your publisher ID as provided to you by Taboola account manager
## Step 2: Init TaboolaJS
In your Application class, enter the following:
No Application Ending Class?
If your project does not have an Application extending class, create one and then init the `
## Step 3: Register the WebView
Before loading the actual content in your webview, register the webview that is intended to contain the Taboola widget.
Make sure to unregister your webview before it is destroyed.
To register the Webview, enter the following in your `
Activity` or `
Taboola recommends to register the webview before loading any content to it. If you register the webview after loading it. please refresh its content
## Step 4: Adding HTML/JS Widget Within the WebView
Your HTML page loaded inside the webview should contain the Taboola mobile JS code. This is to bind with the TaboolaJS native SDK and actually display the widget.
If you are already familiar with the Taboola web JS code, notice that although the Taboola mobile JS code is mostly identical to the Taboola web JS code, there are a few minor modifications to be made.
Place this code in the `
<head>` tag of the webview that will contain the Taboola asset. Make sure you replace the values as described below the code example.
page-type key` - replace the "page-type" key string with the key that represents the type of the page (`
category`, and `
home`). Please use the value given to you by your Taboola account manager
page-type value` - use `
auto` to assign an automated id to the current page. If you wish to pass your own internal ID for the current page, please pass the value instead of `
auto`. For example: `
pass-url-here`: pass the canonical URL (web representation) of the app page - this is needed for Taboola to crawl the page to get contextual and metadata
publisher-id`: replace it with the publisher ID received from your Taboola account manager
Place this code anywhere in the `
<body>` tag of the webview that will contain the Taboola asset. Make sure you replace the values as described below the code example.
container-id`: use any id for the actual widget container element
mode-name`: replace it with the mode parameter received from your Taboola account manager
Placement Name`: use the placement name received from your Taboola account manager
taboola_view_id`: (optional) set view id to prevent duplicated between different placements (can use: `
new Date().getTime()`). Make sure to use this value on any Taboola asset located on the same webview
publisher-id-goes-here`: replace it with the publisher ID received from your Taboola account manager
Do **not** forget to register your webview with the native TaboolaJS object as described in Step 2
## Step 5: Additional Integration Information (Optional)
### 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 clicks, implement the interface `
com.taboola.android.api.TaboolaOnClickListener` and set in the SDK:
**Event: taboolaViewItemClickHandler** <code>boolean taboolaViewItemClickHandler(String url, boolean isOrganic)</code>: 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). <code>URL</code>: The original click URL <code>isOrganic</code>: Indicates whether the item clicked was an organic Taboola content recommendation 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. <code>Return value</code>:
Returning <code>false</code> aborts the click's default behavior. The app displays the Taboola Recommendation content on its own (for example, using an in-app browser).
Returning <code>true</code> means that the click is a standard one and that it is sent to the Android OS for default behavior.
If you want to receive an event about the render status, register the following listener in the <code>TaboolaJs</code> object. Create an <code>OnRenderListener</code>:
Register the above listener with the <code>TaboolaJs</code> object
If you want to receive an event about the widget resize status, register the following listener in the `
Create an `
You can see a code example of the `
### Listenning to errors within the JS tag
It is possible to listen to an error event, a case where Taboola does not serve ads, within the JS tag inside your webview (inside the `
### Working with ViewPager
If your app is implementing ViewPager, it is important to load Taboola's content only when the next screen (page) becomes visible.
lazyFetch:true` to the mobile JS tag inside the `
<body>` tag (see Step 2 above)
Fetch content when view becomes visible (`
## Step 6: Unregister the webview
To unregister a Webview, in your `
Activity` or `
## Step 7: Testing and Examples
You can find code examples on our [Github repository](🔗)
You can use our Android SDK [Integration Verifier special mode ](🔗)
You can use the following parameters for testing and development. Sponsored items are flagged with an <code>SC:</code> prefix in the title; organic items are flagged with an <code>OC:</code> prefix in the title.
|Column Title||Mid article widget||Below article widget|
|<code>placement</code>||"Mid Article"||"Below Article"|
## 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](🔗)