# Secondary methods

## Ad impression

The event is used for individual tracking of ad revenue on user devices. The method is used if there are CPI data available on the client device (they can be obtained from the ad network SDK).

{% hint style="info" %}
Do not apply this method if you use ad networks that utilize the server-server protocol for sending ad revenue data (ironSource, AppLovin MAX, and Fyber networks) and you already set up this method of data collection because if you use both data sources, your revenue data may be duplicated.
{% endhint %}

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}

| Parameter       | Type    | Restrictions                              | Description                                           |
| --------------- | ------- | ----------------------------------------- | ----------------------------------------------------- |
| **`network`**   | String  | from 1 to 100 symbols                     | Name of the ad network responsible for the impression |
| **`revenue`**   | Double  | from 0,0 to Double.max                    | Reward for banner display in USD                      |
| **`placement`** | String? | <p>from 1 to 100 symbols,<br>optional</p> | Banner placement                                      |
| **`unit`**      | String? | <p>from 1 to 100 symbols,<br>optional</p> | Banner name                                           |

```swift
DTDAnalytics.adImpression(network: "Network name",
                          revenue: 0.15,
                          placement: "Placement of the banner",
                          unit: "Banner title")
```

{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}

| Parameter       | Type                    | Restrictions                              | Description                                           |
| --------------- | ----------------------- | ----------------------------------------- | ----------------------------------------------------- |
| **`network`**   | NSString                | from 1 to 100 symbols                     | Name of the ad network responsible for the impression |
| **`revenue`**   | double                  | from 0,0 to Double.max                    | Reward for banner display in USD                      |
| **`placement`** | NSString **\_Nullable** | <p>from 1 to 100 symbols,<br>optional</p> | Banner placement                                      |
| **`unit`**      | NSString **\_Nullable** | <p>from 1 to 100 symbols,<br>optional</p> | Banner name                                           |

```objectivec
[DTDAnalytics adImpressionWithNetwork:@"Network name"
                              revenue:0.15f
                            placement:@"Placement of the banner"
                                unit:@"Banner title"];
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

| Parameter       | Type    | Restrictions                              | Description                                           |
| --------------- | ------- | ----------------------------------------- | ----------------------------------------------------- |
| **`network`**   | String  | from 1 to 100 symbols                     | Name of the ad network responsible for the impression |
| **`revenue`**   | Double  | from 0,0 to Double.max                    | Reward for banner display in USD                      |
| **`placement`** | String? | <p>from 1 to 100 symbols,<br>optional</p> | Banner placement                                      |
| **`unit`**      | String? | <p>from 1 to 100 symbols,<br>optional</p> | Banner name                                           |

```kotlin
DTDAnalytics.adImpression(
    network = "Network name",
    revenue = 0.45,
    placement = "Placement of the banner",
    unit = "Banner title"
)
```

{% endtab %}

{% tab title="Android (Java)" %}

| Parameter       | Type    | Restrictions                              | Description                                           |
| --------------- | ------- | ----------------------------------------- | ----------------------------------------------------- |
| **`network`**   | String  | from 1 to 100 symbols                     | Name of the ad network responsible for the impression |
| **`revenue`**   | Double  | from 0,0 to Double.max                    | Reward for banner display in USD                      |
| **`placement`** | String? | <p>from 1 to 100 symbols,<br>optional</p> | Banner placement                                      |
| **`unit`**      | String? | <p>from 1 to 100 symbols,<br>optional</p> | Banner name                                           |

```java
DTDAnalytics.INSTANCE.adImpression(
        "Network name",
        0.45,
        "Placement of the banner",
        "Banner title"
);
```

{% endtab %}

{% tab title=".NET Native + UWP" %}

| Parameter       | Type    | Restrictions                              | Description                                           |
| --------------- | ------- | ----------------------------------------- | ----------------------------------------------------- |
| **`network`**   | String  | from 1 to 100 symbols                     | Name of the ad network responsible for the impression |
| **`revenue`**   | Double  | from 0,0 to Double.max                    | Reward for banner display in USD                      |
| **`placement`** | String? | <p>from 1 to 100 symbols,<br>optional</p> | Banner placement                                      |
| **`unit`**      | String? | <p>from 1 to 100 symbols,<br>optional</p> | Banner name                                           |

```csharp
var network = "Network name";
var revenue = 0.15;
var placement = "Placement of the banner";
var unit = "Banner title";
DTDAnalytics.AdImpression(network, revenue, placement, unit);
```

{% endtab %}

{% tab title="Unity" %}

| Parameter       | Type    | Restrictions                              | Description                                           |
| --------------- | ------- | ----------------------------------------- | ----------------------------------------------------- |
| **`network`**   | String  | from 1 to 100 symbols                     | Name of the ad network responsible for the impression |
| **`revenue`**   | Double  | from 0,0 to Double.max                    | Reward for banner display in USD                      |
| **`placement`** | String? | <p>from 1 to 100 symbols,<br>optional</p> | Banner placement                                      |
| **`unit`**      | String? | <p>from 1 to 100 symbols,<br>optional</p> | Banner name                                           |

```csharp
var network = "Network name";
var revenue = 0.15;
var placement = "Placement of the banner";
var unit = "Banner title";
DTDAnalytics.AdImpression(network, revenue, placement, unit);
```

{% endtab %}

{% tab title="Unreal" %}
![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2FI2t8TrbF12Fzb0ScOLQo%2Fimage.png?alt=media\&token=4408aa27-bbad-4deb-8f6c-cac86a2c9463)

| **Parameter** | **Type** | **Restrictions**           | **Description**                                           |
| ------------- | -------- | -------------------------- | --------------------------------------------------------- |
| socialNetwork | FString  | from 1 to 100 symbols      | The name of the ad network that delivered the impression. |
| revenue       | float    | form 0.0 to float.MaxValue | Reward for displaying a banner in USD.                    |
| placement     | FString  | from 1 to 100 symbols      | Placement of the banner.                                  |
| unit          | FString  | from 1 to 100 symbols      | Banner title.                                             |

```cpp
UDTDAnalyticsBPLibrary::AdImpression("NetworkName", 0.36, "BannerPlacement", "BannerTitle");
```

{% endtab %}

{% tab title="Godot" %}

| Parameter       | Type   | Restrictions                              | Description                                           |
| --------------- | ------ | ----------------------------------------- | ----------------------------------------------------- |
| **`network`**   | String | from 1 to 100 symbols                     | Name of the ad network responsible for the impression |
| **`revenue`**   | Float  | from 0,0 to Double.max                    | Reward for banner display in USD                      |
| **`placement`** | String | <p>from 1 to 100 symbols,<br>optional</p> | Banner placement                                      |
| **`unit`**      | String | <p>from 1 to 100 symbols,<br>optional</p> | Banner name                                           |

```gdscript
DTDAnalytics.AdImpression("Network name", 0.15, "Placement of the banner", "Banner title")
```

{% endtab %}
{% endtabs %}

## Connecting to social networks

The event is used to track connections to social media channels.

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}
Use the following constants to specify a social network:

***`.facebook, .vkontakte , .twitter, .googleplus, .whatsapp, .viber, .evernote, .googlemail, .linkedin, .pinterest, .qzone, .reddit, .renren, .tumblr`***

Or create an object with the desired social media name.

```swift
let network = DTDSocialNetwork(name: "NetworkName")
DTDAnalytics.socialNetworkConnect(socialNetwork: network)
```

{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}
Use the following constants to specify a social network:

***`.facebook, .vkontakte , .twitter, .googleplus, .whatsapp, .viber, .evernote, .googlemail, .linkedin, .pinterest, .qzone, .reddit, .renren, .tumblr`***

Or create an object with the desired social media name.

```objectivec
DTDSocialNetwork *network = [[DTDSocialNetwork alloc] initWithName:@"NetworkName"];
[DTDAnalytics socialNetworkConnect:network];
```

{% endtab %}

{% tab title="Android (Kotlin)" %}
Use the following constants to specify a social network:

***`DTDSocialNetwork.facebook, DTDSocialNetwork.vkontakte , DTDSocialNetwork.twitter, DTDSocialNetwork.googleplus, DTDSocialNetwork.whatsapp, DTDSocialNetwork.viber, DTDSocialNetwork.evernote, DTDSocialNetwork.googlemail, DTDSocialNetwork.linkedin, DTDSocialNetwork.pinterest, DTDSocialNetwork.qzone, DTDSocialNetwork.reddit, DTDSocialNetwork.renren, DTDSocialNetwork.tumblr`***

Or create an object with the desired social media name.

```kotlin
DTDAnalytics.socialNetworkPost(
    socialNetwork = DTDSocialNetwork.facebook
)
```

{% endtab %}

{% tab title="Android (Java)" %}
Use the following constants to specify a social network:

**`DTDSocialNetwork.Companion.getFacebook(), DTDSocialNetwork.Companion.getVkontakte(), DTDSocialNetwork.Companion.getTwitter(), DTDSocialNetwork.Companion.getGoogleplus(), DTDSocialNetwork.Companion.Whatsapp(), DTDSocialNetwork.Companion.getViber(), DTDSocialNetwork.Companion.getEvernote(), DTDSocialNetwork.Companion.getGooglemail(), DTDSocialNetwork.Companion.getLinkedin(), DTDSocialNetwork.Companion.getPinterest(), DTDSocialNetwork.Companion.getQzone(), DTDSocialNetwork.Companion.getReddit(), DTDSocialNetwork.Companion.getRenren(), DTDSocialNetwork.Companion.getTumblr()`**

Or create an object with the desired social media name.

```java
DTDAnalytics.INSTANCE.socialNetworkConnect(DTDSocialNetwork.Companion.getFacebook());
```

{% endtab %}

{% tab title=".NET Native + UWP" %}
Use the following constants to specify a social network:

***`DTDSocialNetwork.facebook, DTDSocialNetwork.vkontakte , DTDSocialNetwork.twitter, DTDSocialNetwork.googleplus, DTDSocialNetwork.whatsapp, DTDSocialNetwork.viber, DTDSocialNetwork.evernote, DTDSocialNetwork.googlemail, DTDSocialNetwork.linkedin, DTDSocialNetwork.pinterest, DTDSocialNetwork.qzone, DTDSocialNetwork.reddit, DTDSocialNetwork.renren, DTDSocialNetwork.tumblr`***

Or create an object with the desired social media name:

```csharp
var network = new DTDSocialNetwork(name: "NetworkName");
DTDAnalytics.SocialNetworkConnect(socialNetwork: network);
```

{% endtab %}

{% tab title="Unity" %}
Use the following constants to specify a social network:

***`DTDSocialNetwork.facebook, DTDSocialNetwork.vkontakte , DTDSocialNetwork.twitter, DTDSocialNetwork.googleplus, DTDSocialNetwork.whatsapp, DTDSocialNetwork.viber, DTDSocialNetwork.evernote, DTDSocialNetwork.googlemail, DTDSocialNetwork.linkedin, DTDSocialNetwork.pinterest, DTDSocialNetwork.qzone, DTDSocialNetwork.reddit, DTDSocialNetwork.renren, DTDSocialNetwork.tumblr`***

Or create an object with the desired social media name:

```csharp
var network = new DTDSocialNetwork(name: "NetworkName");
DTDAnalytics.SocialNetworkConnect(socialNetwork: network);
```

{% endtab %}

{% tab title="Web" %}

```javascript
analytics.socialNetworkConnect('NetworkName')
```

{% endtab %}

{% tab title="Unreal" %}
![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2F2v3SfsiZIxcCgWUPVKw2%2Fimage.png?alt=media\&token=ccdb002a-7dce-439c-bb95-1a438e81a1a0)

| **Argument**  | **Type**          | **Description**            |
| ------------- | ----------------- | -------------------------- |
| socialNetwork | EDTDSocialNetwork | Predefined social network. |

```cpp
UDTDAnalyticsBPLibrary::SocialNetworkConnect(EDTDSocialNetwork::Linkedin);
```

Or use special method for custom social network:

![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2F8cM6VaJhYjy6atx9OKoR%2Fimage.png?alt=media\&token=ddefc39f-574d-4d8a-8769-22304136e817)

```cpp
UDTDAnalyticsBPLibrary::SocialNetworkConnectCustom("SocialNetworkName");
```

| **Argument**  | **Type** | **Description**        |
| ------------- | -------- | ---------------------- |
| socialNetwork | FString  | Custom social network. |
| {% endtab %}  |          |                        |

{% tab title="Godot" %}
Use the following constants to specify a social network:

***`.facebook, .vkontakte , .twitter, .googleplus, .whatsapp, .viber, .evernote, .googlemail, .linkedin, .pinterest, .qzone, .reddit, .renren, .tumblr`***

```gdscript
DTDAnalytics.SocialNetworkConnect(GDDTDSocialNetwork.Facebook())
```

Or create an object with the desired social media name.

```gdscript
let network = GDDTDSocialNetwork(name: "NetworkName")
DTDAnalytics.SocialNetworkConnect(network)
```

{% endtab %}
{% endtabs %}

## Posting to social networks

Track social media posts and analyze their effectiveness and virality. Pass the event after the post has been approved by social media.

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}

```swift
DTDAnalytics.socialNetworkPost(socialNetwork: .facebook, 
                                      reason: "New level reached")
```

{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}

```objectivec
[DTDAnalytics socialNetworkPost:DTDSocialNetwork.facebook withReason:@"New level reached"];
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
DTDAnalytics.socialNetworkPost(
    socialNetwork = DTDSocialNetwork.facebook,
    reason = "New level reached"
)
```

{% endtab %}

{% tab title="Android (Java)" %}

```java
 DTDAnalytics.INSTANCE.socialNetworkPost(
        DTDSocialNetwork.Companion.getFacebook(),
        "New level reached"
)
```

{% endtab %}

{% tab title=".NET Native + UWP" %}

```csharp
DTDAnalytics.SocialNetworkPost(
    socialNetwork: DTDSocialNetwork.facebook,
    reason: "New level reached");
```

{% endtab %}

{% tab title="Unity" %}

```csharp
DTDAnalytics.SocialNetworkPost(
    socialNetwork: DTDSocialNetwork.Facebook,
    reason: "New level reached");
```

{% endtab %}

{% tab title="Web" %}

```javascript
analytics.socialNetworkPost("NetworkName", "New level reached")
```

{% endtab %}

{% tab title="Unreal" %}
![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2FrHmqcv3EeXJVFBhXDjN9%2Fimage.png?alt=media\&token=83c7b1c3-e31b-4d08-91cb-7424cfc17f42)

| **Argument**  | **Type**          | **Description**            |
| ------------- | ----------------- | -------------------------- |
| socialNetwork | EDTDSocialNetwork | Predefined social network. |

```cpp
UDTDAnalyticsBPLibrary::SocialNetworkPost(EDTDSocialNetwork::Linkedin, "PostReason");
```

![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2FBSzcEcnUy2jFBp6Ii3n1%2Fimage.png?alt=media\&token=c86b95c2-8f55-4c8c-af4a-9ad5817a80c4)

| **Argument**  | **Type** | **Description**        |
| ------------- | -------- | ---------------------- |
| socialNetwork | FString  | Custom social network. |

```cpp
UDTDAnalyticsBPLibrary::SocialNetworkPostCustom("SocialNetworkName", "PostReason");
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
DTDAnalytics.SocialNetworkPost(GDDTDSocialNetwork.Facebook(), "New level reached")
```

{% endtab %}
{% endtabs %}

## Referrer

If you have referral information, you can pass it using the following method:

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}

```swift
let referrerData = [DTDReferralProperty.source: "AdWords",
                    DTDReferralProperty.medium: "CPI",
                    DTDReferralProperty.content: "Snow Boots",
                    DTDReferralProperty.campaign: "Warm Snow Boots",
                    DTDReferralProperty.term: "shoes+boots"]
                    
DTDAnalytics.referrer(utmData: referrerData)
```

{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}

```objectivec
NSDictionary <DTDReferralProperty *, NSString *> * referrerData = @{
  DTDReferralProperty.source: @"AdWords",
  DTDReferralProperty.medium: @"CPI",
  DTDReferralProperty.content: @"Snow Boots",
  DTDReferralProperty.campaign: @"Warm Snow Boots",
  DTDReferralProperty.term: @"shoes+boots",
};
[DTDAnalytics referrer:referrerData];
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
enum class DTDReferralProperty {
    Source,
    Campaign,
    Content,
    Medium,
    Term;
}

val referrer = mapOf(
        DTDReferralProperty.Medium to "some value",
        DTDReferralProperty.Campaign to "some value"
)    
DTDAnalytics.referrer(utmData = referrer)
```

{% endtab %}

{% tab title="Android (Java)" %}

```java
public final enum class DTDReferralProperty {
    Source,
    Campaign,
    Content,
    Medium,
    Term;
}

Map<DTDReferralProperty, String> propertyStringHashMap = new HashMap<>();
propertyStringHashMap.put(DTDReferralProperty.Medium, "some value");
propertyStringHashMap.put(DTDReferralProperty.Campaign, "some value");
DTDAnalytics.INSTANCE.referrer(propertyStringHashMap);
```

{% endtab %}

{% tab title=".NET Native + UWP" %}

```csharp
var referrer = new Dictionary<DTDReferralProperty, string>
{
    [DTDReferralProperty.Medium] = "some value",
    [DTDReferralProperty.Campaign] = "some value"
};
DTDAnalytics.Referrer(referrer: referrer);
```

{% endtab %}

{% tab title="Unity" %}

```csharp
var referrer = new Dictionary<DTDReferralProperty, string>
{
    [DTDReferralProperty.Medium] = "some value",
    [DTDReferralProperty.Campaign] = "some value"
};
DTDAnalytics.Referrer(referrer: referrer);
```

{% endtab %}

{% tab title="Web" %}

```javascript
const referrer = {
    source: "some source",
    term: "some term",
    medium: "some medium",
    source: "some source",
    content: "some content",
    campaign: "some campaign",
};
analytics.referrer(referrer)
```

{% endtab %}

{% tab title="Unreal" %}
![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2Fjkinw3ih5XVns8qLY7i8%2Fimage.png?alt=media\&token=43d8abb4-9b3b-404e-89d6-6e97fa313d7e)

| **Argument** | **Type**                             | **Description** |
| ------------ | ------------------------------------ | --------------- |
| utmData      | TMap\<EDTDReferralProperty, FString> | UTM data.       |

```cpp
TMap<EDTDReferralProperty, FString> referrer;
referrer.Add(EDTDReferralProperty::Source, "Source");
referrer.Add(EDTDReferralProperty::Medium, "Medium ");
referrer.Add(EDTDReferralProperty::Content, "Content ");
referrer.Add(EDTDReferralProperty::Campaign, "Campaign ");
referrer.Add(EDTDReferralProperty::Term, "Term ");
UDTDAnalyticsBPLibrary::Referrer(referrer);
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
var reffer = GDDTDReferralProperty.new()
reffer.AddCampaign("Warm Snow Boots")
reffer.AddContent("Snow Boots")
reffer.AddMedium("CPI")
reffer.AddSource("AdWords")
reffer.AddTerm("shoes+boots")

DTDAnalytics.Referrer(reffer)
```

{% endtab %}
{% endtabs %}

## Force dispatch of accumulated events

To send an event packet before it is full (10 events, by default) or before the end of the period of its formation (2 minutes, by default), you can use immediate dispatch.

{% hint style="info" %}
We don’t recommend using this method unless absolutely necessary!\
When the Real payment event is created, the forced dispatch of the packet occurs automatically.
{% endhint %}

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}

```swift
DTDAnalytics.sendBufferedEvents()
```

{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}

```objectivec
[DTDAnalytics sendBufferedEvents];
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
DTDAnalytics.sendBufferedEvents()
```

{% endtab %}

{% tab title="Android (Java)" %}

```java
DTDAnalytics.INSTANCE.sendBufferedEvents();
```

{% endtab %}

{% tab title=".NET Native + UWP" %}

```csharp
DTDAnalytics.SendBufferedEvents();
```

{% endtab %}

{% tab title="Unity" %}

```csharp
DTDAnalytics.SendBufferedEvents();
```

{% endtab %}

{% tab title="Web" %}

```javascript
analytics.sendBufferedEvents()
```

{% endtab %}

{% tab title="Unreal" %}
![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2Flctoh2jjCwXCQmnvPC1q%2Fimage.png?alt=media\&token=d5fc0722-f0af-407e-b61a-5d7626130932)

```cpp
UDTDAnalyticsBPLibrary::SendBufferedEvents();
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
DTDAnalytics.SendBufferedEvents()
```

{% endtab %}
{% endtabs %}

## Setters & Getters

{% hint style="info" %}
When working with getters you should take into account that the new devtodev SDK is completely asynchronous. The execution result must be processed within the **`completionHandler`**.

All set and get methods need to be called only after the initialization of the SDK.

It is also worth remembering that the SDK will call the callback in background queues, so we recommend that you transfer the processing of return values to the queue you need.
{% endhint %}

For example:

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}

```swift
DispatchQueue.main.async{}
```

{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}

```objectivec
dispatch_async(dispatch_get_main_queue(), ^{ });
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
Handler(Looper.getMainLooper()).post{}
```

{% endtab %}

{% tab title="Android (Java)" %}

```java
ContextCompat.getMainExecutor(context).execute(() -> {
    // This is where your UI code goes.
});
```

{% endtab %}

{% tab title=".NET Native + UWP" %}

```csharp
var result = await DTDAnalytics.GetUserId();
```

{% endtab %}

{% tab title="Unity" %}

```csharp
DTDAnalytics.GetUserId( id => {
  //your code
});
```

{% endtab %}

{% tab title="Unreal" %}
![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2FgI8JevkblxgdS5QoHGjd%2Fimage.png?alt=media\&token=3f0b4606-0392-44f1-a5be-94d9e14bfe70)

| **Argument** | **Type**                                                                                 | **Description** |
| ------------ | ---------------------------------------------------------------------------------------- | --------------- |
| onResult     | <ul><li>FAnalyticsDynamicGetterStringDelegate</li><li>FDTDGetterStringDelegate</li></ul> | Callback.       |

```cpp
auto onResult = new FDTDGetterStringDelegate();
onResult->BindLambda([](const FString& value)
{
	// Your code...
});
UDTDAnalyticsBPLibrary::GetUserId(*onResult);
```

{% endtab %}
{% endtabs %}

### Setting User Tracking Status (GDPR) <a href="#setting-user-tracking-status-gdpr-hardbreak-settrackingavailability" id="setting-user-tracking-status-gdpr-hardbreak-settrackingavailability"></a>

This method denies/allows tracking of user data and also implements the right to be forgotten in accordance with the requirements of the GDPR.

When this method is called with the 'false' value, the SDK sends a command to the server to delete all personal user data that was collected by devtodev in this application, blocking further user data collection.

The user will remain in the devtodev system only as an impersonal unit in the previously aggregated metrics.

If it is set to ‘***true***', tracking can be enabled again. In this case, the user will be considered new.

To enable/disable user tracking by the devtodev system. Bool type.

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}

```swift
DTDAnalytics.setTrackingAvailability(value: true)
```

{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}

```objectivec
[DTDAnalytics trackingAvailability:true];
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
DTDAnalytics.setTrackingAvailability(value = true)
```

{% endtab %}

{% tab title="Android (Java)" %}

```java
DTDAnalytics.INSTANCE.setTrackingAvailability(true);
```

{% endtab %}

{% tab title=".NET Native + UWP" %}

```csharp
DTDAnalytics.SetTrackingAvailability(trackingValue: true);
```

{% endtab %}

{% tab title="Unity" %}

```csharp
DTDAnalytics.SetTrackingAvailability(trackingValue: true);
```

{% endtab %}

{% tab title="Web" %}

```javascript
analytics.setTrackingAvailability(true)
```

{% endtab %}

{% tab title="Unreal" %}
![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2FM2BSyePyb8RTo8whu4FS%2Fimage.png?alt=media\&token=297ff2b5-7d30-49e4-9b87-8f5a5122a18a)

```cpp
UDTDAnalyticsBPLibrary::SetTrackingAvailability(true);
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
DTDAnalytics.SetTrackingAvailability(true)
```

{% endtab %}
{% endtabs %}

### Getting device ID <a href="#getting-device-id-hardbreak-getdeviceid" id="getting-device-id-hardbreak-getdeviceid"></a>

Get device ID. String type.

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}

```swift
DTDAnalytics.getDeviceId { deviceId in
  // your code
}
```

{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}

```objectivec
[DTDAnalytics deviceIdHandler:^(NSString * _Nonnull deviceId) {
  // your code
}];
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
DTDAnalytics.getDeviceId { deviceId ->
  // your code
}
```

{% endtab %}

{% tab title="Android (Java)" %}

```java
DTDAnalytics.INSTANCE.getDeviceId(deviceId ->
        // your code
        null
);
```

{% endtab %}

{% tab title=".NET Native + UWP" %}

```csharp
var devideId = await DTDAnalytics.GetDeviceId();
```

{% endtab %}

{% tab title="Unity" %}

```csharp
DTDAnalytics.GetDeviceId( id => {
  //your code
});
```

{% endtab %}

{% tab title="Web" %}

```javascript
const devideId = analytics.getDeviceId()
```

{% endtab %}

{% tab title="Unreal" %}
![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2FGWDT2xKuD34F4lhZZFow%2Fimage.png?alt=media\&token=a61053ca-a74e-4222-a2b3-c091a166ca0b)

| **Argument** | **Type**                                                                                 | **Description** |
| ------------ | ---------------------------------------------------------------------------------------- | --------------- |
| onResult     | <ul><li>FAnalyticsDynamicGetterStringDelegate</li><li>FDTDGetterStringDelegate</li></ul> | Callback.       |

```cpp
auto onResult = new FDTDGetterStringDelegate();
onResult->BindLambda([](const FString& value)
{
	// Your code...
});
UDTDAnalyticsBPLibrary::GetDeviceId(*onResult);
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
DTDAnalytics.GetDeviceId(getDeviceHandler)

func getDeviceHandler(deviceId: String):
    print(deviceId)
```

{% endtab %}
{% endtabs %}

### Getting the devtodev SDK version <a href="#getting-the-devtodev-sdk-version-hardbreak-getsdkversion" id="getting-the-devtodev-sdk-version-hardbreak-getsdkversion"></a>

Get the version of the integrated devtodev SDK. String type.&#x20;

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}

```swift
DTDAnalytics.getSDKVersion { sdkVersion in
  // your code
}
```

{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}

```objectivec
[DTDAnalytics sdkVersionHandler:^(NSString * _Nonnull sdkVersion) {
  // your code
}];
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
DTDAnalytics.getSDKVersion { sdkVersion ->
  // your code
}
```

{% endtab %}

{% tab title="Android (Java)" %}

```java
DTDAnalytics.INSTANCE.getSdkVersion ( sdkVersion ->
         // your code
         null
);
```

{% endtab %}

{% tab title=".NET Native + UWP" %}

```csharp
var sdkVersion = DTDAnalytics.GetSdkVersion();
```

{% endtab %}

{% tab title="Unity" %}

```
DTDAnalytics.GetSdkVersion( version => {
  //your code
});
```

{% endtab %}

{% tab title="Web" %}

```javascript
const sdkVersion = analytics.getSDKVersion()
```

{% endtab %}

{% tab title="Unreal" %}
![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2FxHciwqjPSTmpjl1Cy4fU%2Fimage.png?alt=media\&token=5a31419c-4f42-4ad9-8a3a-91c680091f07)

| **Argument** | **Type**                                                                                 | **Description** |
| ------------ | ---------------------------------------------------------------------------------------- | --------------- |
| onResult     | <ul><li>FAnalyticsDynamicGetterStringDelegate</li><li>FDTDGetterStringDelegate</li></ul> | Callback.       |

```cpp
// Some codecauto onResult = new FDTDGetterStringDelegate();
onResult->BindLambda([](const FString& value)
{
	// Your code...
});
UDTDAnalyticsBPLibrary::GetSdkVersion(*onResult);
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
DTDAnalytics.GetSdkVersion(getSdkVersionHandler)

func getSdkVersionHandler(sdkVersion: String):
    print(sdkVersion)
```

{% endtab %}
{% endtabs %}

### Obtaining user tracking status (GDPR) <a href="#obtaining-user-tracking-status-gdpr" id="obtaining-user-tracking-status-gdpr"></a>

Retrieving the saved state of the user tracking permission by the devtodev system. See “Setting User Tracking Status”. Bool type.

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}

```swift
DTDAnalytics.getTrackingAvailability { trackingAvailability in
  // your code
}
```

{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}

```objectivec
[DTDAnalytics trackingAvailabilityHandler:^(BOOL trackingAvailability) {
  // your code
}];

```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
DTDAnalytics.getTrackingAvailability { trackingAvailability ->
  // your code
}
```

{% endtab %}

{% tab title="Android (Java)" %}

```java
DTDAnalytics.INSTANCE.getTrackingAvailability( trackingAvailability ->
         // your code
         null
);
```

{% endtab %}

{% tab title=".NET Native + UWP" %}

```csharp
var trackingAvailability = await DTDAnalytics.GetTrackingAvailability();
```

{% endtab %}

{% tab title="Unity" %}

```csharp
DTDAnalytics.GetTrackingAvailability( tracking => {
  //your code
});
```

{% endtab %}

{% tab title="Web" %}

```javascript
const trackingAvailability = analytics.getTrackingAvailability()
```

{% endtab %}

{% tab title="Unreal" %}
![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2FAKRhX5f4cvoXOVomdQCg%2Fimage.png?alt=media\&token=1726d245-e089-4f4a-81f9-4e565ccec1d5)

| **Argument** | **Type**                                                                             | **Description** |
| ------------ | ------------------------------------------------------------------------------------ | --------------- |
| onResult     | <ul><li>FAnalyticsDynamicGetterBoolDelegate</li><li>FDTDGetterBoolDelegate</li></ul> | Callback.       |

```cpp
auto onResult = new FDTDGetterBoolDelegate();
onResult->BindLambda([](bool value)
{
	// Your code...
});
UDTDAnalyticsBPLibrary::GetTrackingAvailability(*onResult);
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
DTDAnalytics.GetTrackingAvailability(getTrackingAvailabilityHandler)

func getTrackingAvailabilityHandler(trackingAvailability: bool):
    print(str(trackingAvailability))
```

{% endtab %}
{% endtabs %}

### Getting devtodev ID <a href="#getting-devtodev-id" id="getting-devtodev-id"></a>

devtodev ID is the primary numeric identifier for the device/user account in the devtodev database. Using devtodev ID, you are sure to find the user in devtodev.

The identifier will be received from the server some time after the initialization of the SDK.

If you have set counting by users, a separate devtodev id will be issued for each device user.

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}
To obtain the devtodev ID, you need to pass the listener to **`DTDAnalytics`**:

```swift
DTDAnalytics.setIdentifiersListener(listener: self)
```

The delegate must implement the **`func didReceiveDevtodevId(with devtodevId: Int)`**

```swift
func didReceiveDevtodevId(with devtodevId: Int) {
  /// your code
}
```

The **`didReceiveDevtodevId`** method will be called with every ID change on the server side.
{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}
To obtain the devtodev ID, you need to pass the listener to **`DTDAnalytics`**:

```objectivec
@interface Controller ()  <DTDIdentifiersListener>
[DTDAnalytics setIdentifiersListenerWithListener:self];
```

The delegate must implement the **`(void)didReceiveDevtodevIdWith:(NSInteger)devtodevId;`**

```objectivec
- (void)didReceiveDevtodevIdWith:(NSInteger)devtodevId {
  // your code
}
```

The **`didReceiveDevtodevId`** method will be called with every ID change on the server side.
{% endtab %}

{% tab title="Android (Kotlin)" %}
To obtain the devtodev ID, you need to pass the **`DTDIdentifiersListener`** listener to **`DTDAnalytics`**:

```kotlin
DTDAnalytics.setIdentifiersListener(object : DTDIdentifiersListener {
            override fun didReceiveDevtodevId(devtodevId: Long) {
               /// your code
            }
        })
```

The `didReceiveDevtodevId` method will be called with every ID change on the server side.
{% endtab %}

{% tab title="Android (Java)" %}
To obtain the devtodev ID, you need to pass the **`DTDIdentifiersListener`** listener to **`DTDAnalytics`**:

```java
DTDAnalytics.INSTANCE.setIdentifiersListener(new DTDIdentifiersListener() {
            @Override
            public void didReceiveDevtodevId(long devtodevId) {
                // your code
            }
});
```

The `didReceiveDevtodevId` method will be called with every ID change on the server side.
{% endtab %}

{% tab title=".NET Native + UWP" %}
To obtain the devtodev ID, you need to pass the **`DTDIdentifiersListener`** listener delegate to **`DTDAnalytics`**:

```csharp
DTDAnalytics.SetIdentifiersListener(devtodevId =>
{
    // Your code...
});
```

The `delegate` method will be called with every ID change on the server side.
{% endtab %}

{% tab title="Unity" %}
To obtain the devtodev ID, you need to pass the **`DTDIdentifiersListener`** listener delegate to **`DTDAnalytics`**:

```csharp
DTDAnalytics.SetIdentifiersListener(devtodevId =>
{
    // Your code...
});
```

The `delegate` method will be called with every ID change on the server side.
{% endtab %}

{% tab title="Web" %}

```javascript
analytics.setIdentifiersListener((devtodevId) =>
{
// Your code...
})
```

{% endtab %}

{% tab title="Unreal" %}
![Blueprint](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LnGcP_ZeRJ1ipj9O8dF%2Fuploads%2FcD9PZ53kbGYwASOZUbum%2Fimage.png?alt=media\&token=67651326-5103-470e-9397-179378c2a906)

| **Argument** | **Type**                                                                             | **Description**       |
| ------------ | ------------------------------------------------------------------------------------ | --------------------- |
| listener     | <ul><li>FAnalyticsDynamicGetterLongDelegate</li><li>FDTDGetterLongDelegate</li></ul> | devtodev ID Listener. |

```cpp
auto listener = new FDTDGetterLongDelegate();
listener->BindLambda([](int64 value)
{
	// Your code...
});
UDTDAnalyticsBPLibrary::SetIdentifiersListener(*listener);
```

{% endtab %}

{% tab title="Godot" %}
To obtain the devtodev ID, you need to pass the `Callable` to **`DTDAnalytics`**:

```gdscript
DTDAnalytics.SetIdentifiersCallback(identifiersUpdated)

func identifiersUpdated(devtodevID: int):
    print("SetIdentifiersCallback DevtodevID is " + str(devtodevID))
```

The **`didReceiveDevtodevId`** method will be called with every ID change on the server side.
{% endtab %}
{% endtabs %}

## Initialization callback

To receive a callback when the SDK initialization is complete, you can use a method that will implement the initialization callback. When the SDK completes the initialization, the callback will be called on the main application thread.

{% hint style="info" %}
We recommend implementing a callback before calling initialization.
{% endhint %}

{% tabs fullWidth="true" %}
{% tab title="iOS+macOS (Swift)" %}

```swift
DTDAnalytics.setInitializationCompleteCallback {
  print("Initialized has been finished.")
}
let config = DTDAnalyticsConfiguration()
config.logLevel = .error
DTDAnalytics.initialize(applicationKey: "App ID", configuration: config)
```

{% endtab %}

{% tab title="iOS+macOS (Objective-C)" %}

```objectivec
[DTDAnalytics setInitializationCompleteCallback:^{
  NSLog(@"%@", @"Initialized has been finished.");
}];
DTDAnalyticsConfiguration *config = [[DTDAnalyticsConfiguration alloc] init];
config.logLevel = DTDLogLevelError;
[DTDAnalytics applicationKey:@"App ID" configuration:config];
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
DTDAnalytics.setInitializationCompleteCallback {
    Log.d("TAG", "Initialized has been finished.")
}
val config = DTDAnalyticsConfiguration()
config.logLevel = DTDLogLevel.Error
DTDAnalytics.initialize(appKey = "App ID", analyticsConfiguration = config, context = this)
```

{% endtab %}

{% tab title="Android (Java)" %}

```java
DTDAnalytics.INSTANCE.setInitializationCompleteCallback(() -> {
    Log.d("TAG", "Initialized has been finished.");
    return null;
});
DTDAnalyticsConfiguration config = new DTDAnalyticsConfiguration();
config.setLogLevel(DTDLogLevel.Error);
DTDAnalytics.INSTANCE.initialize("App ID", config, this);
```

{% endtab %}

{% tab title=".NET Native + UWP" %}

```csharp
DTDAnalytics.LogLevel = DTDLogLevel.Error;
DTDAnalytics.SetInitializationCompleteCallback(()=>Console.WriteLine($"Initialization has been finished"));
DTDAnalytics.Initialize("APP_KEY");
```

{% endtab %}

{% tab title="Unity" %}

```csharp
DTDAnalytics.SetInitializationCompleteCallback(() =>
{
    Debug.Log("Initialized has been finished.");
});

DTDAnalytics.SetLogLevel(DTDLogLevel.Error);
DTDAnalytics.Initialize("APP_KEY");
```

{% endtab %}

{% tab title="Web" %}

```javascript
analytics.setInitializationCompleteCallback(() =>
{
// Your code...
})
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
func initCompleteCallback():
  print("Initialized has been finished.")

func _ready():
  DTDAnalytics.SetInitializationCompleteCallback(initCompleteCallback)
  var config = GDDTDAnalyticsConfiguration.new()
  config.logLevel = GDDTDLogLevel.Error
  DTDAnalytics.InitializeWithConfig(appKey, config)
```

{% endtab %}
{% endtabs %}


---

# 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://docs.devtodev.com/integration/integration-of-sdk-v2/setting-up-events/secondary-methods.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.
