Forum Discussion

DRamirez's avatar
DRamirez
Practitioner III
2 years ago

Nested custom attributes in Custom HTML messages

Hi everybody!

I am currently working on a HTML multipage survey IAM. There are 7 different topics that i want to ask users their level of interest on (with a scale from 1 to 5). I was thinking of making a nested custom attribute to keep the amount of different custom attributes for the same survey at a minimum. 

My question is; does anybody know if it is possible to send a nested custom attribute to Braze with javascript? (I am not that well versed in javascript :D)

  • Hi DRamirez ! You should have no problem logging nested custom attributes using the Javascript Bridges. I'm curious though; let us know if you were successful with this!

    • DRamirez's avatar
      DRamirez
      Practitioner III

      Hi Allan!
      We could thankfully make it happen, and we indeed used the Javascript bridge! The only obstacle that we are currently having is that for some reason the nested attribute isn't saved/registered when the IAM is shown on an Android device. On iOS everything works perfectly and gets saved in the user's profile.

       

  • Hey DRamirez,

    Yes, it is possible! To do this, you need to store your information in a JSON object variable like this:

    const json = {
      "song_name": "Solea",
      "artist_name": "Miles Davis",
      "album_name": "Sketches of Spain",
      "genre": "Jazz",
      "play_analytics": {
        "count": 1000,
        "top_10_listeners": true
      }
    };

     Next, you have to call the appboyBridge.getUser().setCustomUserAttribute() function like this:

    appboyBridge.getUser().setCustomUserAttribute("most_played_song", json);

     If you have questions, you can check out the Braze WebSDK documentation, since the methods are the same but modified for the appboyBridge usage. Let me know if you have any further questions! 🙂 

     

    Best,

    Max

    • DRamirez's avatar
      DRamirez
      Practitioner III

      Hi Max! Thanks for the answer!

      This is what I have been using and it seems to work perfectly for iOS, but for some reason, it will not work with Android. I contacted Braze eventually and the conclusion was that it was something that had to be requested in the product roadmap unfortunately 😅