Autoform Hooks and okgrow:analytics

After my autoform submits, I’d like to send an

analytics.track('Name of Event', { propertyName: submittedDocument.property });

but I can’t figure out how to do this in an autoform hook.

I’m using a type=method autoform, so I can’t put the analytics event with that method (as it’s on the server side). I put it in an onSuccess hook, and it submits the event to mixpanel but I can’t send any properties about the submitted document along with it as the onSuccess hook doesn’t have info about the document… and I’m not sure how to pass it along to it.

Is there another hook I should be using that has access to the document?

The autoform hooks section of the documentation is a little esoteric for newbies.

Probably the best option is to return the analytics data from the meteor method, so then it is accessible in the onSuccess hook. Another option is to install/write a package to enable sending server-side analytics. For a platform like Mixpanel which gathers a lot of statistics from the client’s web browser however, you lose a lot of built-in data collection by going the server-side route.

1 Like

^ hero.

this worked.