Custom Attributes

Prev Next

Overview

Custom Attributes in Android enable developers to personalize user experiences by storing and utilizing user-specific data such as names, birthdays, or preferences. These attributes allow dynamic segmentation and messaging, enhancing engagement and user retention.

Use Case

  1. Purpose:

    • Store user-specific data for personalization.

    • Segment users based on attributes to deliver targeted campaigns.

  2. Benefits:

    • Enhance user experience with tailored content and offers.

    • Facilitate analytics and reporting by categorizing users effectively.

Implementation Details

  1. Set Custom Attributes:

    • Assign attributes like strings, numbers, or dates using the SDK.

      // Set a string value
      Appoxee.instance().setAttribute("userName", "JohnDoe");
      
      // Set a numeric value
      Appoxee.instance().setAttribute("userScore", 150);
      
      // Set a date value
      Date birthDate = new SimpleDateFormat("yyyy-MM-dd").parse("2000-01-01");
      Appoxee.instance().setAttribute("userBirthday", birthDate);
  2. Retrieve Custom Attributes:

    • Fetch stored attributes for application logic or reporting.

      // Get a string value
      String userName = Appoxee.instance().getAttributeStringValue("userName");
      
      // Get a numeric value
      Number userScore = Appoxee.instance().getAttributeNumericValue("userScore");
      
      // Get a date value
      Date userBirthday = Appoxee.instance().getAttributeDateValue("userBirthday");
  3. Increment Numeric Attributes:

    • Update numeric values dynamically.

      Appoxee.instance().incrementNumericAttribute("userScore", 10);

Keep in mind:

  • Attributes are key-value pairs where keys are strings, and values can be strings, numbers, or dates.

  • Ensure attribute names are unique and meaningful.

  • Test attribute setting and retrieval for different scenarios and data types.