Install the Flutter SDK
This guide walks you through installing and configuring the MarkTag Flutter SDK in your project.
Installation
1. Install the package
From your project root, add the SDK using your preferred command:
bash
flutter pub add marktagbash
dart pub add marktagYou can also add the dependency manually via pub.dev/packages/marktag.
2. Import the SDK
Import the MarkTag SDK in your application code:
dart
import 'package:marktag/marktag.dart';3. Initialize the SDK
Initialize MarkTag in your main() function before calling runApp(). Ensure Flutter bindings are initialized first:
dart
void main() {
WidgetsFlutterBinding.ensureInitialized();
const domain = 'your-domain.com';
const serverId = 'your-server-id';
Marktag.instance.init(
tag: domain,
serverId: serverId,
enableLogging: true,
);
runApp(const MyApp());
}- Set
domainto the tag value from your MarkTag project settings (replace'your-domain.com'with your real host). - Set
serverIdto the value shown in your MarkTag dashboard under Data room → Setup data container → Server side → View configuration. This is what attributes events to your tenant when multiple integrations share the same host. - Set
enableLoggingtofalseto disable debug logs in production.
Client-side mode — when many tenants share one tracking host (for example mtag.markopolo.ai), pass your client id through the tagId parameter so events are attributed to the correct merchant:
dart
void main() {
WidgetsFlutterBinding.ensureInitialized();
const domain = 'your-domain.com';
const clientId = 'your-client-id';
Marktag.instance.init(
tag: domain,
tagId: clientId, // SDK parameter is named `tagId`; the value is your client id
enableLogging: true,
);
runApp(const MyApp());
}- Set
domainto the shared tracking host (for example your white-label domain ormtag.markopolo.ai). - Set
clientIdto the value shown in your MarkTag dashboard under Data room → Setup data container → Client side → View configuration (or from the Partner API). The SDK passes it under thetagIdparameter name for backward compatibility, but it is sent to the server asclientId.
INFO
Default events (like on the web) are not supported in the mobile SDK.