# Events

Netmera offers a complete set of trackable events, giving you valuable insights into user behavior and app performance. These events fall into two main categories: ***Standard Events***, which include Automated and Pre-defined Events and ***Custom Events**.*

{% hint style="success" %}
**Detailed Event Definitions:**

For detailed information on event definitions, please consult our [User Guide.](https://user.netmera.com/netmera-user-guide/customer-data/events/netmera-events)
{% endhint %}

<figure><img src="/files/s3ADZ8O1BTe9PQ1QZe0U" alt=""><figcaption></figcaption></figure>

### Automated Events

Netmera's Automated Events begin tracking automatically upon SDK integration—no further setup is required. These tracked events include:

* App Installs
* App Opens
* Push Receipts (requires dashboard configuration)
* Push Opens
* Log Events
* Time in App
* Geofence Enter/Exit (requires geofence setup)
* Web View Actions

### Pre-defined Events

Pre-defined Events are built-in, ready-to-use events that you can easily integrate into your application. These events come with pre-written code examples to simplify implementation. You can trigger these events using the provided sample code patterns:

<details>

<summary>Pre-defined Events List</summary>

**Screen View Event**: Logs when a specific screen is viewed.

**Login Event**: Captures user login actions.

**Register Event**: Tracks user registration actions.

**Search Event**: Records search actions performed by users.

**Share Event**: Logs when content is shared from the app.

**In-App Purchase Event**: Captures in-app purchase transactions.

**Banner Click Event**: Tracks clicks on banners within the app.

**Category View Event**: Logs views of specific categories.

**Battery Level Event**: Monitors the battery level during app usage.

**Product View Event**: Tracks when a product is viewed.

**Product Rate Event**: Logs when a product is rated.

**Product Comment Event**: Captures comments made on products.

**Order Cancel Event**: Records when an order is canceled.

**Purchase Event**: Logs completed purchase transactions.

**Cart View Event**: Tracks views of the shopping cart.

**Add To Cart Event**: Captures when items are added to the cart.

**Remove From Cart Event**: Logs when items are removed from the cart.

**Add To Wishlist Event**: Tracks when items are added to a wishlist.

**Content Comment Event**: Captures comments made on content.

**Content Rate Event**: Logs ratings given to content.

**Content View Event**: Tracks views of media content.

</details>

{% tabs %}
{% tab title="Flutter" %}

```dart
// Define a method to send a login event
void sendLoginEvent() {
    // Create a new instance of the NetmeraEventLogin event
    NetmeraEventLogin loginEvent = new NetmeraEventLogin();

    // Send the event using Netmera's sendEvent method
    Netmera.sendEvent(loginEvent);
}
```

{% endtab %}
{% endtabs %}

### Custom Events

Custom Events provide flexibility beyond the standard and pre-defined options to allow you to track specific user interactions and behaviors within your application.

#### Step 1: Define the Event in the Netmera Panel

1. Go to the **Netmera Panel** and navigate to **Developers > Events > Create New Event** section.
2. Create a new event and specify the event parameters.
3. Set parameter types, define mandatory fields, and configure arrays if required.
4. Refer to the [**Creating Custom Events**](https://user.netmera.com/netmera-user-guide/customer-data/events/creating-custom-events) guide for detailed instructions.

<figure><img src="/files/cdKxyaP325o5KRbvgLRu" alt="" width="563"><figcaption></figcaption></figure>

#### Step 2: Import the Generated Code

1. After creating the event, **Netmera** generates a code snippet.
2. Import this generated code into your project to integrate the custom event.

<figure><img src="/files/Xq9JTsnfwF6TnfGzGHsF" alt="" width="563"><figcaption><p>Sample Generated Code</p></figcaption></figure>

#### Step 3: Extend the Event Class in Your Code

1. Choose a built-in event subclass or extend from `NetmeraEvent`.
2. Define event parameters and ensure they match the panel setup.

#### Step 4: Fire the Event

1. Make sure the event is correctly set up in the **Netmera Panel** before triggering it.
2. Implement the event call in your application code.

{% hint style="warning" %}
**Ensure Mandatory Parameters Are Included**

If a required parameter is missing, the request will fail with a ***bad request*** error. Always send mandatory parameters to avoid rejection.
{% endhint %}

#### Custom Events Sample Codes

When you create an event on the panel, you will receive a code. You are supposed to import the code the panel created for you in your project. Below you will see examples.

{% tabs %}
{% tab title="Flutter" %}

```dart
import 'package:netmera_flutter_sdk/events/media/NetmeraEvent.dart';
import 'package:quiver/core.dart';
import 'dart:core';

class SampleEvent extends NetmeraEvent {
  final String _EVENT_CODE = "puzzf";

  SampleEvent() : super();

  @override
  String eventCode() {
    return _EVENT_CODE;
  }

  @override
  Map<String, dynamic> toJson() {
    Map<String, dynamic> map = super.toJson();
    return map;
  }
}
```

{% endtab %}
{% endtabs %}

### Generic Events

Generic Events let you track user interactions on the fly — no code import, no auto-generated class extensions required. This approach is best suited for fast implementation and dynamic tracking scenarios.

#### Event Flows

Depending on your account configuration, Generic Events support two different custom event flows:

<table><thead><tr><th width="310.961181640625">Flow</th><th>Description</th></tr></thead><tbody><tr><td><strong>Panel-defined Custom Event Flow</strong></td><td>Events must be created in the Netmera Panel before they are sent from the SDK.</td></tr><tr><td><strong>Generic Custom Event Flow</strong></td><td>Events can be sent directly from the SDK without prior panel configuration. Requires the Generic Custom Event offer to be enabled on your account.</td></tr></tbody></table>

#### Why Use Generic Events?

* **No code import required.** Start tracking immediately after defining the event in the panel.
* **Flexible by design.** Add or update event parameters without modifying class structures.
* **Lightweight.** Eliminates the need for multiple event-specific classes, keeping your project clean.

#### Generic Custom Event Flow

> **Account requirement:** This flow requires the Generic Custom Event feature to be enabled. Contact your Success Manager to activate it.

With this flow, events can be fired from the SDK without creating an event definition in the Netmera Panel first.

#### Sending an Event

Fire the event using the event key and a parameter map:

```dart
Netmera.sendGenericEvent('<EVENT_CODE>', {
    '<ATTRIBUTE_NAME>': '123',
    '<ATTRIBUTE_NAME>': 99.99,
    '<ATTRIBUTE_NAME>': DateTime.now(),
});
```

**How Netmera Processes the Event**

<table><thead><tr><th width="233.718017578125">Condition</th><th>Behavior</th></tr></thead><tbody><tr><td>Event already exists</td><td>Accepted and written under the related app key and user.</td></tr><tr><td>Event does not exist</td><td>Created automatically, then written under the related app key and user.</td></tr><tr><td>Custom event limit reached</td><td>Request is rejected and an error is returned. No new event is created.</td></tr></tbody></table>

### Revenue Event

Revenue tracking records and reports user purchase transactions. For example, if a user clicks a push notification, opens your app, and makes a purchase during that session, you can log this as revenue data. This helps measure how effective the push notification was in driving revenue.

* Use `event.setRevenue()` to assign a revenue value to any event (custom or standard).
* Revenue data appears in push reports **only if** the user opens the app after clicking the push notification.
* Any events (like purchases) that happen during the session triggered by the push click are linked to that notification in your reports.

#### How to Implement Revenue Tracking

If a user makes a purchase after clicking a push notification and opening your app, send the revenue data to Netmera like this:

{% tabs %}
{% tab title="Flutter" %}

```dart
NetmeraEvent customEvent = NetmeraEvent();
customEvent.setUserId("TestUserId");
customEvent.setRevenue(100);
Netmera.sendEvent(customEvent);
```

{% endtab %}
{% endtabs %}

### Importing Events to Apps

If you have multiple apps in the Netmera Panel, you can import events from one app to another. This lets you reuse events across apps efficiently.

1. Go to the **Developers** section and select **Events.**
2. Click **Import Event Definition.**
3. Choose the **Application Name** from which you want to import events.

<figure><img src="/files/QdzMUtMEUWhP264HKBNB" alt="" width="563"><figcaption></figcaption></figure>

1. Select the specific **custom event(s)** you want to import.
2. Click the **Import** button in the **Action** section.

<figure><img src="/files/QniKsjEs64GcviJ94ehY" alt="" width="268"><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://user.netmera.com/netmera-developer-guide/platforms/flutter/events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
