Hi bot, hi hope you are doing well. I'am using the flutter sdk and I would like to increase a User Profile Properties. I'am using the correct method (increment) but even after few minutes it didn't appear in the user profile. Can you help me with it please ?
Hi Cyril, Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> đź‘‹
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
I'd be happy to help you with incrementing User Profile Properties in Mixpanel using the Flutter SDK.When using the .increment()
method in the Flutter SDK, you need to make sure you've properly identified the user first. Here's the correct sequence of steps: 1. First, make sure you've called .identify()
with the user's distinct ID before attempting to increment properties
2. Then use the .getPeople().increment()
method to update numeric propertiesHere's an example of the correct implementation: LBKS// First identify the user mixpanel.identify('1234');LBKS// Then set initial properties if needed mixpanel.getPeople().set({ 'name': 'sam', 'age': 25 });LBKS// Increment "age" by 2 mixpanel.getPeople().increment('age', 2);LBKS
If your implementation follows this pattern but the property still isn't appearing, here are some things to check: 1. Verify that you've initialized the Mixpanel instance correctly with your project token
2. Make sure you're calling .identify()
before any profile updates
3. Check that you're incrementing a numeric property (non-numeric properties can't be incremented)
4. Confirm your network connectivity, as profile updates require an internet connectionThe Flutter SDK's increment method triggers requests to Mixpanel's /engage API endpoint, and it should update the profile property by adding the specified value to its current value (or to 0 if the property doesn't exist yet).Mixpanel Flutter SDK documentation shows that you can also use negative values to decrement properties if needed.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Thanks for the answer. Everything you said is ok and work well.
Let me check the knowledge base for you again. One moment! 📚
I'm sorry to hear that both .getPeople().increment()
and .getPeople().set()
aren't working for you. Let's troubleshoot this issue with the Flutter SDK.The most common reason profile updates don't appear is that the .identify()
method hasn't been properly called before setting profile properties. According to the Mixpanel documentation: > You must call .identify()
before setting profile properties in order to associate the profile properties you set with the target user. If identify is not called, the profile update will be queued for ingestion until an identify call is made.
Mixpanel SDKs: FlutterHere are some specific things to check: 1. Verify the identify call is happening first:
// Only after identify, call people methods
mixpanel.getPeople().set("Plan", "Premium");
```LBKSLBKS2. **Check that you're using the correct distinct ID** - make sure it matches what you're looking for in the Mixpanel interface.LBKS3. **Confirm the Mixpanel instance is properly initialized** with your project token.LBKS4. **Look for any error messages** in your console logs that might indicate what's going wrong.LBKS5. **Remember that the `mixpanel.identify()` call does not create a User Profile** by itself. As mentioned in the documentation:
> The mixpanel.identify() call does not create a User Profile in Mixpanel. The people.set() method is the required call to set user properties on a user profile.
[Identity Management Best Practices](https://docs.mixpanel.com/guides/implement/send-your-data#identity-management-best-practices)LBKSIf you've verified all these steps and it's still not working, you might want to try a simple test case with just the basic implementation to isolate the issue: LBKSLBKS```LBKS// Initialize Mixpanel (make sure this is done once at app startup)
// Then in your user login flow:
mixpanel.identify("test_user_123");
mixpanel.getPeople().set("test_property", "test_value");LBKS```LBKSLBKSIf you're still experiencing issues, it might be worth checking if there are any network connectivity problems or if there are any specific configuration settings in your Mixpanel project that could be affecting profile updates.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Let me check the knowledge base for you again. One moment! 📚
Thank you for providing that additional information. It seems you're specifically having issues with the Mixpanel Flutter SDK in a web browser environment.This could be related to how the Flutter SDK interacts with web browsers. The Mixpanel Flutter SDK is designed to work across platforms, but there might be specific considerations for web implementations.Here are some potential issues and solutions for web browser implementations: 1. Browser storage limitations: Web browsers have different storage mechanisms and security policies that might affect how Mixpanel stores and sends data.2. Network requests: Check if the network requests to Mixpanel's API are being blocked by browser security features or CORS policies.3. Initialization for web: Make sure you're initializing Mixpanel correctly for web environments.4. Delayed processing: In web environments, profile updates might take longer to appear in the Mixpanel interface due to batching or caching.Unfortunately, the knowledge sources provided don't contain specific information about Flutter SDK implementation issues in web browsers. The documentation primarily covers the general usage of the Flutter SDK without platform-specific troubleshooting.I'd recommend: 1. Checking your browser console for any error messages related to Mixpanel 2. Verifying that your web app has proper network permissions 3. Testing with a simple event tracking first (before profile updates) to see if that works 4. Ensuring you're using the latest version of the Mixpanel Flutter SDKIf you continue to experience issues, you might want to reach out to Mixpanel's support team directly, as this appears to be a platform-specific implementation issue that isn't covered in the general documentation.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Let me check the knowledge base for you again. One moment! 📚
Thank you for the update. This is an important clue that helps narrow down the issue. Since your Mixpanel profile updates are working on iOS with Flutter but not in the web browser environment, this points to a specific web implementation issue.Looking at the documentation, there's a key difference in how the Flutter SDK works in web environments: For Flutter Web specifically, the documentation mentions that you need to add a special snippet to your web/index.html
file: LBKS<script src="./assets/packages/mixpanel_flutter/assets/mixpanel.js"> </script> LBKS
This script needs to be placed inside the <head> </head>
tag in your project's HTML file Flutter SDK documentation.Additionally, when using Flutter for web, you might need to initialize Mixpanel differently. The documentation states that for Flutter Web specifically, you should add your proxy server to the mixpanel.init
call: LBKSmixpanel.init("<YOUR_PROJECT_TOKEN> ", {api_host: "https://<YOUR_PROXY_DOMAIN> "});LBKS
This is different from the mobile implementation Flutter SDK documentation.Another potential issue could be ad blockers in the web browser. The documentation mentions that web tracking can be unreliable due to ad blockers, which might block requests to Mixpanel's domains Guide to choosing your data architecture.Since it's working on iOS, your implementation logic is likely correct, but you may need these web-specific adjustments to make it work in browser environments.Would you like me to provide more specific guidance on setting up a proxy for web tracking to avoid ad blocker issues?
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Let me check the knowledge base for you again. One moment! 📚
I understand that the issue with your Flutter web implementation is related to the proxy. This makes sense, as ad blockers and browser security features often block direct requests to analytics domains like Mixpanel.For Flutter web applications, you need to set up a proxy to route your Mixpanel tracking requests through your own domain. Here's how to properly implement this: 1. Set up a proxy server - The simplest way is to use Mixpanel's sample nginx configuration from their tracking proxy repository.2. Configure your Flutter web app to use the proxy:
mixpanel.init("<YOUR_PROJECT_TOKEN> ", {api_host: "https://<YOUR_PROXY_DOMAIN> "});
```LBKSLBKS3. **For non-web Flutter platforms**, you would use a different method:
```LBKS // For mobile platforms
mixpanel.setServerURL("https://<YOUR_PROXY_DOMAIN> ");
```LBKSLBKSThis explains why your implementation works on iPhone but not in web browsers - the proxy configuration is different between platforms [Flutter SDK documentation](https://docs.mixpanel.com/docs/tracking-methods/sdks/flutter#tracking-via-proxy).LBKSAlso, make sure you've added the required script to your web/index.html file: LBKS```LBKS<script src="./assets/packages/mixpanel_flutter/assets/mixpanel.js"> </script> LBKS```LBKSLBKSSetting up the proxy correctly should resolve the issue with profile updates not appearing when using Flutter web.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Let me check the knowledge base for you again. One moment! 📚
I'm glad to hear that you resolved the issue with your proxy configuration! This is a common challenge when implementing Mixpanel with Flutter web applications, as the proxy setup is crucial for ensuring that tracking requests aren't blocked by ad blockers or browser security features.For anyone else who might encounter similar issues, remember that proper proxy configuration is essential for web implementations of Mixpanel, as mentioned in the Flutter SDK documentation.Is there anything else you'd like to know about implementing Mixpanel with Flutter, or do you have any other questions about your implementation?
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.