---
updatedAt: 2025-09-28T14:10:59.000Z
agentTools:
  projectIndex: https://developers.taboola.com/taboolasdk/llms.txt
---

# Event Handling

*iOS Web* - Event Handling

> ✅
>
> While reading the documentation, take a look at our [Sample App](https://developers.taboola.com/taboolasdk/v4/docs/sample-code).

## TBLWebPageDelegate

When fetching and displaying **Taboola** content, you may need to handle certain events. *Taboola Web Integration* provides a `TBLWebPageDelegate` for event handling.

## Available Events

### didClickPlacementName

An item in the placement was clicked.

> 👍 Use Case
>
> Use this method to intercept the *click* event, and open *organic* content directly within your app.

```objectivec
- (BOOL)webView:(WKWebView *)webView didClickPlacementName:(NSString *)placementName itemId:(NSString *)itemId clickUrl:(NSString *)clickUrl isOrganic:(BOOL)organic customData:(NSDictionary *)customData{
    // Insert your code here...
    // Return 'NO' to handle the click event yourself - or 'YES' for Taboola to handle it.
    // Note: you can override the default behavior for *organic* content only.
    return YES;
}
```
```swift
func webView(_ webView: WKWebView!, didClickPlacementName placementName: String!, itemId: String!, clickUrl: String!, isOrganic organic: Bool, customData: [AnyHashable : Any]!) -> Bool{
    // Insert your code here...
    // Return 'false' if you are handling the click event yourself, or 'true' if you want Taboola SDK to handle the click event.
    // Note: you can override the default behavior for *organic* content only.
    return true;
}
```

> 📘 Callback params
>
> * `webView` - A reference to your web view component.
> * `placementName` - The name of the clicked placement - e.g.: `Feed without video`.
> * `itemId` - The *ID* of the clicked item.
> * `clickUrl` - The *Click URL* of the clicked item.
> * `organic` - A boolean value, indicating if the clicked item is *organic*. (If not, then you *cannot* override the click behavior.)

> 📘 Return value
>
> * Return `true` (or `YES` for *Obj C*) to indicate that **Taboola SDK** should open the *Click URL*.
> * Return `false`  (or `NO` for *Obj C*) to prevent **Taboola SDK** from opening the *Click URL* (allowing you to handle it).

> 🚧
>
> You can override the default behavior for *organic* content *only*.

### didLoadPlacementName

The Taboola placement rendered successfully within your web content.

```objectivec
- (void)webView:(WKWebView *)webView didLoadPlacementName:(NSString *)placementName height:(CGFloat)height {
    NSLog(@"%@", placementName);
    // Insert your code here...
}
```
```swift
class MyWebViewController: TBLWebPageDelegate {

    ...

    func webView(_ webView: WKWebView!, didLoadPlacementName placementName: String!, height: CGFloat) {
        print("Placement name: \(String(describing: placementName)) has been loaded with height: \(height)")
        // Insert your code here...
    }
}
```

> 📘 Params
>
> * `webView` - A reference to your web view component.
> * `placementName` - The name of the placement that *rendered* - e.g. "`Feed without video`".
> * `height` - The height, in pixels, of the **Taboola** content rendered.

### didFailToLoadPlacementName

The Taboola placement *failed* to render within your web content.

```objectivec
- (void)webView:(WKWebView *)webView didFailToLoadPlacementName:(NSString *)placementName errorMessage:(NSString *)error {
    NSLog(@"%@", error);
    // Insert your code here...
}
```
```swift
class MyWebViewController: TBLWebPageDelegate {

    ...
    func webView(_ webView: WKWebView!, didFailToLoadPlacementName placementName: String!, errorMessage error: String!) {
        print("Error: \(String(describing: error))")
    }
}
```

> 📘 Params
>
> * `webView` - A reference to your web view component.
> * `placementName` - The name of the placement that failed to render - e.g. "`Feed without video`".
> * `error` - The error message. (See below for possible values.)

#### Possible values for `error`:

| Value            | Description                        |
| :--------------- | :--------------------------------- |
| `NO_ITEMS`       | No Taboola content was returned.   |
| `WRONG_PARAMS`   | The wrong `tb_mode` was submitted. |
| `RESPONSE_ERROR` |                                    |
| `TIMEOUT`        | A connectivity issue occurred.     |
| `UNKNOWN_ERROR`  | An unknown error occurred.         |
| `INTERNAL_1`     | An internal server error occurred. |

## Listening for errors within the JS tag

### Overview

Typically, event handling is performed within your *application code*, as described above.

Should you choose to perform event handling within your *web content*, see the instructions that follow.

### Code

As described under [Basic Integration](https://developers.taboola.com/taboolasdk/docs/ios-sdk-web-basic-integration#add-taboola-javascript), **each placement** is implemented via a JS tag in the `<body>` of your *web content*.

You can optionally add a `noContent` event listener to each of those JS tags.

```html
<script type="text/javascript">

...

_taboola.push({
    // To handle a 'nocontent' error via JS, add this code snippet:
    listenTo: "nocontent",
    handler: function(data) {
        // your error handling code goes here  
    }
});
</script>
```

> 💁🏻 Need a hand?
>
> Go ahead! Ask a question in our [Support Forum](https://sdk.taboola.com/taboolasdk/discuss).
>
> **Tip**: Provide as much detail as possible, including your platform and SDK version.