I am working on implementing mixpanel tracking for the first time. I am tracking events/users correctly and they are showing up within the live view just fine.
However when I assign a value to a property (say $email) from a dictionary by accessing the key that I’m interested in, no data is sent to mixpanel about that property. I have only successfully sent property data to mixpanel when assigning a variable that was assigned to by accessing the key from the dictionary.
Here’s a sample script that I set up demonstrating what I wrote above. Is this approach not possible? Will I need to assign the value of the key that I’m interested to a variable each time and then assign that variable to the property I’m interested in?
Thanks for your time in helping with this.
<script>
var newUserDict = {
"email" : "adrian@awesome.com",
"howHeard" : "facebook"
}
var emailVar = newUserDict["email"]
var howHeardVar = newUserDict["howHeard"]
console.log("email var " + emailVar);
console.log("howHeard var " + howHeardVar);
var mixpanelButton = document.getElementById("test-button")
mixpanelButton.setAttribute('onClick', 'AccountCreated("'+newUserDict+'")')
function AccountCreated(newUserDict) {
mixpanel.track("Sign Up Test",{
//not successfully sending to mp
"$email": newUserDict["email"],
"How Heard": newUserDict["howHeard"],
"email222": newUserDict.email,
"How Heard222": newUserDict.howHeard,
//successfully sending to mp
"email3": emailVar,
"hh": howHeardVar
});
}
</script>