Analytics with Segment Discussion
Great episode Chris! Would be awesome to see some more detailed episodes both for client and server side implementations.
Would be great to see more details on how/why to choose client/server/mixed solutions and keep them in sync (I guess for some of the actions only FE can be used, but for others BE would be safer). How to build a bit more robust analytics tracking system with a bunch of analytics events without polluting/slowing down your code. (For instance creating a wrapper class for all analytics events, when to use BG jobs or when to use promises on FE, etc.). So basically a system design for a more complex segment implementation. I think this is also a great opportunity to show how to structure 3rd party code (as there can be many events in different places) and still writing clean ruby code.
Yeah, for some things for example you may want to track form submissions. Frontend code generally would just track the form submitting, but not whether or not it was successful. This can be useful and you may want to know attempted submissions vs successful submissions as an example.
You're not going to be slowing down your code in either case. Frontend runs in the user's browser so it won't slow anything down. Server-side events are submitted in asynchronously so they won't affect the speed of your code there either.
As for complex integrations, generally analytics are just designed to be an additional line of code that runs in your logic. You will already have methods or classes for that logic so you'd just drop in an additional line to says "Purchase complete" after running through your payments code.
I'll try to come up with an example to go a bit more in-depth on. Generally analytics aren't anything too complex, you've just gotta make sure you write good names for events so they make sense when you're analyzing them later. :)
Lots of places in the video where I think you meant to edit in a cut, but instead left all of the re-takes in. It didn't make a difference to me, but you might want to be more thorough with editing (especially on the pro videos).
For anyone that wants to see a very detailed implementation of Segment within a real world Rails SaaS app, I wrote extensively about that here: https://robsobers.com/9-dol...
For anyone who isn't seeing events load in the debugger:
Make sure you have any adblockers switched off for localhost:3000 or any other website with this that you're testing!
Is it better to use track in html like <"script">analytics.track<"/script"> or in segment.js in asset pipeline?
If I have my identify in JS, is it possible to use user data for the server side? Is it the new cloud method (instead device)?