[Solved!] Sending data to Segment

Options
Hi all,

Has anyone had success setting up Segment yet? I might be close but I still don't have data flowing yet.

As far as I've gotten is making this custom function that attempts to post data to Segment. It returns a "200" code so I believe that means it's working?

Step 1: Function setup to send data to Segment[Screen Shot 2022-07-26 at 2.57.55 PM.png]Step 2: Call the function side a Get Request my UI is already using for a tracking event.
[image.png]Final Result: Debugger looks good (?) but Segment doesn't tell me data is flowing
[Screen Shot 2022-07-26 at 3.01.41 PM.png]

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Just an update from office hours: We figured out Segment always sends a 200 status code and all debugging is done inside their debugger. We were able to figure out, per Segment's documentation, we needed to add a colon to the end of the auth key and apply the base64_encode filter. This got us a successful call. 
  • Alex Rothera
    Alex Rothera Member
    Options
    Thanks Michael! Yes we did it!

    I'll try and release the function on Xano soon, but just quickly here is how to send data to Segment below:
    [Screen Shot 2022-07-29 at 11.36.09 AM.png][Screen Shot 2022-07-29 at 11.39.30 AM.png][Screen Shot 2022-07-29 at 11.39.41 AM.png]
  • liam
    liam Member
    Options
     Thanks so much man, do we have to integrate SDK with xano or just straight use segment's API ?
  • Alex Rothera
    Options
    I didn't do any integration. Just sent it and all good
  • jason.jones
    Options

    What happened to the screenshots? I am trying to do the same thing 😭 I think I have an idea of what to do, but this seems to be exactly what I need to implement a solution! Any help is appreciated!

  • jakespirek
    jakespirek Member, Administrator

    ADMIN

    Options

    Hi @jason.jones (and @Erun I think this might help you too) — 

    While again we don't provide support for other API's, this is something that got worked through in a past office hours as Michael mentioned above.

    According to Segment's API documentation:

    Segment returns a 200 response for all API requests except errors caused by large payloads and JSON errors (which return 400 responses.) To debug events that return 200 responses but aren’t accepted by Segment, use the Segment Debugger.

    Also, according to their documentation, you need to a colon to the end of the Segment auth key and apply the base64_encode filter to that.

    Keep in mind they also use Authorization: Basic instead of Bearer. Then you can use replace or sprintf to add the base64 version of the auth key.

    Hope that helps!