Skip to main content

Analytics with Segment Discussion

General • Asked by Chris Oliver

Great episode Chris! Would be awesome to see some more detailed episodes both for client and server side implementations.

Got any specifics you'd like to see?

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...

Funny, this is the very reason I'm implementing Segment right now. Rob's article is pretty awesome in terms of the things you can do with such a cheap / free marketing stack.


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!


Hi Chris,
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)?
Thanks


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.