VKWebAppTrackEvent

VKWebAppTrackEvent sends data from a mini app or game to VK Ads.

Example

JavaScript
bridge.send('VKWebAppTrackEvent', { event_name: 'game_event', custom_user_id: '743784479', event_params: { level: 5, mode: 123 } }) .then((data) => { if (data.result) { // Data sent } }) .catch((error) => { // Error console.log(error); });

Platforms

Android, iOS, Mobile Web, Web

Parameters

Field
Type
Description
event_name mandatory
string
Event name. An event is an action predefined in the code, such as a purchase made through the app or a user signing in to a game. Events in VK Ads
custom_user_id optional
string
The identifier of the mini app or game user, such as a VK profile ID.
event_params optional
string
Parameters of the event_name.

Result

You can check the result via:

  • •

    The Promise object, which is returned by calling bridge.send(...).

  • •

    The VKWebAppTrackEventResult and VKWebAppTrackEventFailed events.

More about checking the results of VK Bridge calls.

Promise object

If the call is successful, the execution flow goes to the then method of the Promise object. In its response, the platform returns an object with the following field:

Field
Type
Description
result
boolean
true if the data was sent.

If an error occurs, the execution flow goes to the catch method. In its response, the platform returns an object with error information, which is common for all VK Bridge events.

Events

VKWebAppTrackEventResult

The event signals that the data has been sent. The following data is sent to the user-side event handler:

JavaScript
{ detail: { type: "VKWebAppTrackEventResult", data: { result: true } } }

The passed object is similar to the object returned by successful Promise execution.

VKWebAppTrackEventFailed

The event signals about an error that occurred while interacting with the platform.

The user-side event handler receives an object with error information, which is common for all VK Bridge methods.

Example event processing

See the Processing results section.