No feedback with the Flutter SDK

Hello, I need to integrate PiwikPro for my clients.
I’m using the SDK for Flutter with the following configuration:

final result = await flutterPiwik.configureTracker(
  baseURL: 'https://preim.containers.piwik.pro',
  siteId: 'ee3ebbd3-XXXX-XXXX-XXXX-8bc61a575b62',
);

I have no error or warning messages in my console, on the contrary, I get success messages “FlutterPiwikPro - configureTracker completed with parameters: baseURL: https://preim.containers.piwik.pro, siteId: ee3ebbd3-XXXX-XXXX-XXXX-8bc61a575b62” or “FlutterPiwikPro - trackScreen completed with parameters: screenName: test, title: test title”.

We use the same site for our website, and it works correctly.

Thank you in advance for your help.

@M_Devilliers welcome to our Community forum!
Can you clarify what is the problem you are struggling with?

@TymekGF Thank you for your quick feedback !

I configured the SDK and added several tracking (screen views and application installs).
The configuration is correct because it is identical to the one used for our website.
Except that I can’t find any data from my application in the dashboard or the debugger.

Thanks for the clarification.
Can you just confirm:

  • you have the definition for flutterPiwik in this file and it points to FlutterPiwikPro.sharedInstance(),
  • you double checked the siteID and
  • you imported ‘package:flutter_piwikpro/flutter_piwikpro.dart’ to your project file

I’d like to make sure that your setup has all the required details, sorry if this sounds too basic.

For this point, I checked directly in the Administration page.

Otherwise, I confirm the other points that you approach.

What I don’t understand, I tried to use the example provided with the SDK for Flutter. And this one doesn’t work either, is there a configuration in the dashboard that I haven’t forgotten?

import 'package:flutter/material.dart';
import 'package:flutter_piwikpro/model/ecommerce_transaction_item.dart';
import 'package:flutter_piwikpro/flutter_piwikpro.dart';

void main() {
  final ecommerceTransactionItems = [
    EcommerceTransactionItem(
        category: 'cat1', sku: 'sku1', name: 'name1', price: 20, quantity: 1),
    EcommerceTransactionItem(
        category: 'cat2', sku: 'sku2', name: 'name2', price: 10, quantity: 1),
    EcommerceTransactionItem(
        category: 'cat3', sku: 'sku3', name: 'name3', price: 30, quantity: 2),
  ];

  runApp(MyApp(
    ecommerceTransactionItems: ecommerceTransactionItems,
  ));
}

class MyApp extends StatelessWidget {
  const MyApp({
    required this.ecommerceTransactionItems,
    Key? key,
  }) : super(key: key);

  final List<EcommerceTransactionItem> ecommerceTransactionItems;

  @override
  Widget build(BuildContext context) {
    FlutterPiwikPro flutterPiwik = FlutterPiwikPro.sharedInstance;

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Padding(
          padding: const EdgeInsets.only(left: 32.0, right: 32.0, bottom: 32.0),
          child: Center(
            child: SingleChildScrollView(
              child: Column(
                children: [
                  _buildTextWidget('Configure Tracker', () async {
                    try {
                      final result = await flutterPiwik.configureTracker(
                        baseURL: 'https://preim.containers.piwik.pro',
                        siteId: 'ee3ebbd3-****-****-****-8bc61a575b62',
                      );
                      print(result);
                    } catch (exception) {
                      print(exception);
                    }
                  }),
                  _buildTextWidget('Set Anonymization State True', () async {
                    try {
                      final result =
                          await flutterPiwik.setAnonymizationState(true);
                      print(result);
                    } catch (exception) {
                      print(exception);
                    }
                  }),
                  _buildTextWidget('Set Anonymization State False', () async {
                    try {
                      final result =
                          await flutterPiwik.setAnonymizationState(false);
                      print(result);
                    } catch (exception) {
                      print(exception);
                    }
                  }),
                  _buildTextWidget(
                    'Track Screen',
                    () async {
                      try {
                        final result = await flutterPiwik.trackScreen(
                            screenName: "test", title: "test title");
                        print(result);
                      } catch (exception) {
                        print(exception);
                      }
                    },
                  ),
                  _buildTextWidget('Track Custom Event', () async {
                    try {
                      final result = await flutterPiwik.trackCustomEvent(
                          action: 'test action',
                          category: 'test category',
                          name: 'test name',
                          path: 'test path',
                          value: 120);
                      print(result);
                    } catch (exception) {
                      print(exception);
                    }
                  }),
                  _buildTextWidget('Track Exception', () async {
                    try {
                      final result = await flutterPiwik.trackException(
                          description: "description of an exception");
                      print(result);
                    } catch (exception) {
                      print(exception);
                    }
                  }),
                  _buildTextWidget('Track Download', () async {
                    try {
                      final result = await flutterPiwik.trackDownload(
                          'http://your.server.com/bonusmap2.zip');
                      print(result);
                    } catch (exception) {
                      print(exception);
                    }
                  }),
                  _buildTextWidget('Track Ecommerce Transaction', () async {
                    try {
                      final result =
                          await flutterPiwik.trackEcommerceTransaction(
                        identifier: "testId",
                        grandTotal: 100,
                        subTotal: 10,
                        tax: 5,
                        shippingCost: 100,
                        discount: 6,
                        transactionItems: ecommerceTransactionItems,
                      );
                      print(result);
                    } catch (exception) {
                      print(exception);
                    }
                  }),
                  _buildTextWidget('Track Social Interaction', () async {
                    try {
                      final result = await flutterPiwik.trackSocialInteraction(
                          network: "facebook", interaction: "like");
                      print(result);
                    } catch (exception) {
                      print(exception);
                    }
                  }),
                  _buildTextWidget('Track goal', () async {
                    try {
                      final result = await flutterPiwik.trackGoal(
                          goal: "27ecc5e3-8ae0-40c3-964b-5bd8ee3da059",
                          revenue: 2.0);
                      print(result);
                    } catch (exception) {
                      print(exception);
                    }
                  }),
                  _buildTextWidget('Track outlink', () async {
                    try {
                      final result = await flutterPiwik
                          .trackOutlink("piwikPRO://piwikpro.com");
                      print(result);
                    } catch (exception) {
                      print(exception);
                    }
                  }),
                  _buildTextWidget('Track campaign', () async {
                    try {
                      final result = await flutterPiwik.trackCampaign(
                          "http://www.example.com?utm_campaign=camp_name3&pk_source=source&pk_medium=medium&pk_keyword=keyword&pk_content=content&pk_cid=id_code");
                      print(result);
                    } catch (exception) {
                      print(exception);
                    }
                  })
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }

  Widget _buildTextWidget(String title, VoidCallback? onPressed) {
    return TextButton(
      onPressed: onPressed,
      child: Container(
        color: Colors.blue,
        child: Text(
          title,
          style: const TextStyle(color: Colors.white),
        ),
      ),
    );
  }
}

Let me take it with our developers, I’ll get back to you when I got their feedback.

@M_Devilliers we found the error and it seems to be on our end.
In the documentation, we instruct to put the baseURL: 'https://preim.containers.piwik.pro' but it is supposed to be 'https://preim.piwik.pro', I will handle the change of the documentation.

Can you try this way?

I just tried this solution from the example I provided above and this fix works!

Thank you for your help and responsiveness :muscle:

1 Like

At your service!
Enjoy using our product!