The Profiles API enables your ability to increase personalized content based on detailed customer information. This REST API returns customer data in real-time and updates your segment information.

You can also use Profiles API to personalize your customers experience on your website. You can combine Treasure Data’s personalization feature with A/B Testing tools such as Adobe Target, Optimizely, or Google Optimize, to determine the version of your website that yields results.

When the underlying personalization workflow completes, the personalization data set is refreshed. You can see a current list of the segments to which a specific profile belongs. You can also see a list of attributes associated with the specific profile.

Learn more about Profiles API in this video:

Requirements

The master segment must already exist in Master Segments. The master segment is the basis for all data accessed by Profiles API Tokens.

Typically, the use of Profiles API with your tools requires the use of the Treasure Data JavaScript SDK and support or services consultation.

Profiles API is supported for JavaScript SDK v1.9.1 or later. If you're using the old version, you must upgrade.

Specifying Profiles and Segments in the API Token


  1. Navigate to Audience Studio > Profiles API Tokens.


  2. Select New Token.


  3. Complete the fields to configure the API token, including specifying a key column and the segments to which you want to apply personalization. Specify the attributes that you want the token to return values for. The token reads values from an app client or web page. The values are added to the profiles in Treasure Data.


    You use Add Segment to associate the profile API token with one or more segments. The API Token returns attributes data to the profiles that match the specified key and that are in the specified segments.

    By connecting to the token, a client, typically a JavaScript embedded in HTML or tool such as Google tag manager, recognizes profiles by the key and returns attribute values. It is what we call Personalization. The more personalized the profile is, the more customized services or information can be provided to the owner of the profile through activation. 


  4. Save your token.

  5. Optionally, use the TD JavaScript SDK to fetch profile segment IDs. You can apply the segment IDs in your tools to push highly personalized communications to profiles or control what is shown to profiles in the specified segments. Typically this requires that you work with our support or services team. You add Treasure Data SDK script into your client by including the following:

    • API Request

      • audienceToken: List of Profiles API Tokens

      • keys: List of key columns

    • API Response

      • values: Object of values, attributes, key and audienceId

  6. Your tool (such as Optimizely or Google Chrome Developer Tools) accesses the client to retrieve the segment IDs.

  7. Copy tokens that you created and add them to your JS SDK script as follows:

<!-- Treasure Data -->
<script type="text/javascript"> !function(t,e){if(void 0===e[t]){e[t]=function(){e[t].clients.push(this),this._init=[Array.prototype.slice.call(arguments)]},e[t].clients=[];for(var r=function(t){return function(){return this["_"+t]=this["_"+t]||[],this["_"+t].push(Array.prototype.slice.call(arguments)),this}},s=["addRecord","blockEvents","fetchServerCookie","fetchGlobalID","fetchUserSegments","resetUUID","ready","setSignedMode","setAnonymousMode","set","trackEvent","trackPageview","trackClicks","unblockEvents"],n=0;n<s.length;n++){var c=s[n];e[t].prototype[c]=r(c)}var o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src=("https:"===document.location.protocol?"https:":"http:")+"//cdn.treasuredata.com/sdk/2.5/td.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(o,a)}}("Treasure",this);
</script>
<script>
  var td = new Treasure({...})
  
  var successCallback = function (values) {
    /* values format => [... {
      key: {
        [key]:value
      },
      values: ["1234"],
      attributes: {
        age: 30
      },
  
    } ... ]*/
    // celebrate();
  };
  
  var errorCallback = function (error) {
    // cry();
  };
  
  td.fetchUserSegments({
    audienceToken: ['YOUR_PROFILES_API_TOKEN_1', 'YOUR_PROFILES_API_TOKEN_2'],
    keys: {
      someKey: 'someValue',
      someOtherKey: 'someOtherValue',
    }
  }, successCallback, errorCallback)
</script>Example Profile Output

Here’s the example output with Google Chrome Developer Tools.


Optionally Integrate with Other Tools

To control the content that shows for specific customer segments, you can integrate Profiles API with other tools such as:


  • No labels