ozw_sei
ozw_sei

Reputation: 135

How to track engagement and people into mixpanel with one call

This is mixpanel question.

I need to track engagement and people param in one call.

<script>
function signupFunc(){
     mixpanel.people.set({
        "$email": "[email protected]",
        "vpc":0
    });
</script>
<script>
mixpanel.identify("11111");
mixpanel.people.increment("vpc", 1);
mixpanel.track("View Page");
</script>

Upvotes: 1

Views: 211

Answers (1)

Matt Zeunert
Matt Zeunert

Reputation: 16561

You can't update the user profile property and trigger the event in a single Mixpanel call.

Instead you can use a wrapper function like this:

function trackEvent(eventName, eventData){
    mixpanel.track(eventName, eventData);
    mixpanel.people.increment("eventCount - " + eventName, 1);
}

trackEvent("View Page", {});

The user profile will then have a property called "eventCount - View Page")

Upvotes: 1

Related Questions