Fingerprint is a device intelligence platform offering visitor identification and device intelligence with industry-leading accuracy. Fingerprint Flutter SDK is an easy way to integrate Fingerprint into your Flutter application. The plugin allows you to call the underlying native Fingerprint agents (Android, iOS, and Web) and identify devices.
- Flutter 3.13 or higher
- Dart 3.3 or higher
- Android 5.0 (API level 21+) or higher
- iOS 13+/tvOS 15+, Swift 5.7 or higher (stable releases)
We aim to keep the Flutter compatibility policy.
Add fpjs_pro_plugin
to the pubspec.yaml
file in your Flutter app:
dependencies:
flutter:
sdk: flutter
...
fpjs_pro_plugin: ^3.3.2
Run flutter pub get
to download and install the package.
To use this plugin on the web, add the JavaScript agent loader <script>
tag to the <head>
of your HTML template inside the web/index.html
file:
<head>
<!-- ... -->
<script src="assets/packages/fpjs_pro_plugin/web/index.js" defer></script>
</head>
To identify visitors, you need to sign up for a Fingerprint account (there is a free trial available).
- Go to the Fingerprint Pro dashboard.
- Navigate to App Settings > API Keys to find your Public API Key.
Initialize the Fingerprint Flutter plugin inside a StatefulWidget, for example, in the initState
method.
Use the Public API key and region of your Fingerprint workspace (US region is used by default).
import 'package:fpjs_pro_plugin/fpjs_pro_plugin.dart';
import 'package:fpjs_pro_plugin/region.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
State<MyApp> createState() => _MyAppState();
}
// Initialization
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
doInit();
}
void doInit() async {
await FpjsProPlugin.initFpjs(
'<PUBLIC_API_KEY>', // insert your API key here
region: Region.us // or Region.eu, Region.ap
);
}
// ...
}
To avoid ad blockers, we recommend proxying requests from your application to Fingerprint servers through one of our proxy integrations. See Evading ad blockers with proxy integrations for more information.
To use a proxy integration, you can configure endpoint
, scriptUrlPattern
, and their fallbacks.
void doInit() async {
await FpjsProPlugin.initFpjs(
'<PUBLIC_API_KEY>',
region: Region.us,
// Your proxy integration identification endpoint
endpoint: 'https://metrics.yourwebsite.com',
endpointFallbacks: ['https://api.fpjs.io'], // region-specific fallback
// Your proxy integration script URL pattern
// Only necessary for the web platform
scriptUrlPattern: 'https://metrics.yourwebsite.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js',
scriptUrlPatternFallbacks: [
'https://fpjscdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js',
],
);
}
Use getVisitorId
to get just the visitor ID, or getVisitorData
to get the identification response object.
import 'package:fpjs_pro_plugin/fpjs_pro_plugin.dart';
import 'package:fpjs_pro_plugin/region.dart';
import 'package:fpjs_pro_plugin/error.dart';
// ...
class _MyAppState extends State<MyApp> {
void identify() async {
try {
var visitorId = await FpjsProPlugin.getVisitorId();
var visitorData = await FpjsProPlugin.getVisitorData();
print('Visitor ID: $visitorId');
print('Visitor data: $visitorData');
} on FingerprintProError catch (e) {
// Process the error
print('Error identifying visitor: $e');
// See lib/error.dart to get more information about error types
}
}
}
By default, getVisitorData()
will return a short response (FingerprintJSProResponse
).
Pass extendedResponseFormat: true
to the initFpjs
function to get an extended response (FingerprintJSProExtendedResponse
).
void doInit() async {
await FpjsProPlugin.initFpjs('<PUBLIC_API_KEY>', extendedResponseFormat: true);
}
The visitorId
provided by Fingerprint Identification is especially useful when combined with information you already know about your users, for example, account IDs, order IDs, etc. To learn more about various applications of the linkedId
and tag
, see Linking and tagging information.
void identify() async {
const tags = {
'userAction': 'login',
'analyticsId': 'UA-5555-1111-1'
};
const linkedId = 'user_1234';
visitorId = await FpjsProPlugin.getVisitorId(linkedId: linkedId, tags: tags);
deviceData = await FpjsProPlugin.getVisitorData(linkedId: linkedId, tags: tags);
}
Default timeout value:
- iOS: 60 seconds
- Android: not specified
- Web: 10 seconds
You can override the default timeout with a custom value of your choice. If the getVisitorId()
or getVisitorData()
call does not complete within the specified (or default) timeout, you will receive a ClientTimeoutError
error.
void identify() async {
visitorId = await FpjsProPlugin.getVisitorId(timeoutMs: 10000);
deviceData = await FpjsProPlugin.getVisitorData(timeoutMs: 10000);
}
To report problems, ask questions, or provide feedback, please
use Issues. If you need private support, please
email us at [email protected]
.
This project is licensed under the MIT license.