idxdmp 2.4.13
idxdmp: ^2.4.13 copied to clipboard
IDX DMP flutter SDK.
IDX Data Manager Provider Flutter SDK #
This guide provides detailed instructions for integrating and using the IDX Data Manager Provider SDK in your Flutter applications.
This SDK is designed to automatically add user audiences (targeting parameters) to ad requests. There are two approaches for audience calculation - native and via WebView connector.
-
The native approach is suitable when you display your content directly in the mobile application and know the required targeting parameters such as title, description, author, and others.
-
The WebView connector helps when you display your content inside a
WebViewand your content resides on a web page. In this case, the content data will be automatically processed by the Web SDK (which must be installed on the page you want to display in the WebView) and passed to theDMPWebViewConnector. This way, you can use this data on the native side of your application.
Table of Contents #
- Requirements
- Installation
- App configuration
- Integration with DataManagerProvider
- Integration with DMPWebViewConnector
- Author
- Support
- License
Requirements #
To integrate this SDK into your project, you need:
- Android 7.0 (API level 24) or above
- Swift 5.7+
- iOS 12.0+
- Valid ProviderId from IDX
Installation #
IdxDmpSdk is available through [pub.dev][https://pub.dev/packages/idxdmp]
flutter pub get idxdmp
App configuration #
iOS #
Add these keys to your Info.plist file:
<key>NSUserTrackingUsageDescription</key>
<string>It makes our adwords more compatibility with your interests</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>It makes our adwords more compatibility with your location</string>
Run sh pod install in your ios directory
Android #
No any special actions are required
Integration with DataManagerProvider #
To use the SDK in your app, create a Idxdmp instance and call initSdk method with your ProviderId (obtained from IDX). You must also specify your app name and version.
The SDK initializes asynchronously. While you can wait for the completion callback, you can immediately use other SDK methods. In this case, audience calculations will be based on previous data.
Audiences are calculated based on Page View events, which you can send when needed (e.g., when a user opens a new article). You control what data to include in each event.
The SDK returns an object containing the generated userId and collected audiences. To get targeted ads based on this data, set these parameters in your Google ad request.
For integration testing:
- Handle errors in SDK initialization and events
- The object returned by
getCustomAdTargetingshould always contain data - The dxseg key may be empty if no audiences matched, but
userIdwill always be populated
import 'package:idxdmp/idxdmp.dart';
Future<void> run() async {
var idxdmpPlugin = Idxdmp();
try {
var dmpIsInit = await idxdmpPlugin.initSdk('Your Provider ID goes here', 'My flutter app', '1.0.0') ?? false;
if (dmpIsInit) {
await idxdmpPlugin.sendEvent(<String, String>{
url: "/examplePage", // Replace with the specific page URL or identifier
title: "Example Page Title", // Replace with the specific page title
domain: "your-domain.com", // Replace with your domain
author: "author", // Replace with the author of the page
category: "category", // Replace with the category of the page
description: "This is an example page.", // Replace with the description of the page
tags: "tag1, tag2, tag3", // Replace with the tags related to the page
});
var customData = await _idxdmpPlugin.getCustomAdTargeting(); // Map<String, String>
// Now we need to make an ad request with our custom parameters.
// For this, we can use Google Ad Manager - https://pub.dev/packages/google_mobile_ads
var adManagerAdRequest = AdManagerAdRequest(
customTargeting: customData,
)
}
} on PlatformException {
// Handle errors
}
}
Integration with DMPWebViewConnector #
If your app uses WebView to display content but you want to request ads natively, use DMPWebViewConnector. Initialize it with WebViewController and your app name and version.
The connector automatically listens to events from the web page and provides access to audiences calculated by the web SDK. Subsequent integration is identical to DataManagerProvider.
If you have multiple webviews, you need to create a separate DMPWebViewConnector for each of them. DMPWebViewConnector is just a small bridge, so it has practically no overhead.
import 'package:webview_flutter/webview_flutter.dart'
import 'package:idxdmp/idxdmp.dart';
Future<void> run() async {
try {
var webViewController1 = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
var webViewController2 = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
var connector1 = DMPWebViewConnector(webViewController, 'My flutter app', '1.0.0')
var connector2 = DMPWebViewConnector(webViewController, 'My flutter app', '1.0.0')
await webViewController1.loadRequest(Uri.parse("YOUR-SITE-LINK"));
await webViewController2.loadRequest(Uri.parse("YOUR-SITE-LINK"));
var customParameters1 = await connector1.getCustomAdTargeting(); // Map<String, String>
var customParameters2 = await connector2.getCustomAdTargeting(); // Map<String, String>
// Now we need to make an ad request with our custom parameters.
// For this, we can use Google Ad Manager - https://pub.dev/packages/google_mobile_ads
var adManagerAdRequest1 = AdManagerAdRequest(
customTargeting: customParameters1,
)
var adManagerAdRequest2 = AdManagerAdRequest(
customTargeting: customParameters2,
)
} on PlatformException {
// Handle errors
}
}
Author #
IDX LTD, https://www.id-x.co.il/
Support #
For support, report issues in the issue tracker or reach out through our designated support channels
License #
IdxDmpSdk is available under the MIT license. See the LICENSE file for more info.