Visit our new documentation site! This documentation page is no longer updated.

Personalization API with Marketo Web Personalization

You can integrate Treasure Data’s Personalization API with Marketo’s Web Personalization feature to provide fully personalized experience for your customers by leveraging all of your customer data.

Table of Contents

Prerequisites

Step 1: Enable Marketo Web Personalization

First, make sure that you have access to Marketo’s Web Personalization feature. It is a Marketo add-on feature.

Step 2: Configure the Content

Click the Marketo logo and then click Web Personalization.

Click Segments.

Click Create New.

Set the segment number that you created in Treasure Data and the click Save.

Move to Campaign. (Click the Marketo logo and click Campaign.) Then, click Create New Web Campaign.

Select the segment name that you created previously and set the contents. (You can make Dialog, In Zone and Widget.)

Step 3: Implement JavaScript Tags

Step 3-1: Add Marketo RTP Tag

Load Market’s Web Personalizaition JavaScript tag into your page.

Here’s the example tag.

<!-- Marketo RTP tag -->
(function(c,h,a,f,e,i){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
c[a].p=e;c[a].a=i;var g=h.createElement("script");g.async=true;g.type="text/javascript";
g.src=f;var b=h.getElementsByTagName("script")[0];b.parentNode.insertBefore(g,b)})
(window,document,"rtp","[rtp-js-cdn-url]","[pod-url]","[accountId]");
rtp('setAccount', 'YOUR_MARKETO_ACCOUNT_ID');

Step 3-2: Send Treasure Data’s Segment IDs to Marketo as User Context

Call Treasure Data’s Personalization API, and send the response to Marketo using the User Context feature of Marketo’s RTP tag.

Here’s the final outcome of this documentation.

<script type="text/javascript">
<!-- Marketo RTP -->
(function(c,h,a,f,e,i){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
c[a].p=e;c[a].a=i;var g=h.createElement("script");g.async=true;g.type="text/javascript";
g.src=f;var b=h.getElementsByTagName("script")[0];b.parentNode.insertBefore(g,b)})
(window,document,"rtp","[rtp-js-cdn-url]","[pod-url]","[accountId]");
rtp('setAccount', 'YOUR_MARKETO_ACCOUNT_ID');

<!-- Treasure Data -->
!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","set","trackEvent","trackPageview","trackClicks","ready","fetchGlobalID","fetchUserSegments"],a=0;a<s.length;a++){var c=s[a];e[t].prototype[c]=r(c)}var n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=("https:"===document.location.protocol?"https:":"http:")+"//cdn.treasuredata.com/sdk/1.9.2/td.min.js";var i=document.getElementsByTagName("script")[0];i.parentNode.insertBefore(n,i)}}("Treasure",this);

// Configure an instance for your database
var td = new Treasure({
  host: 'in.treasuredata.com',
  writeKey: '[YOUR_WRITE_KEY]',
  database: '[YOUR_DB_NAME]'
});

// Enable cross-domain tracking
td.set('$global', 'td_global_id', 'td_global_id');

// Get segment number from TD and send it to Marketo's RTP
var successCallback = function(key, values) {
  // http://developers.marketo.com/javascript-api/web-personalization/user-context/
  rtp('set', 'customVar1', values.join(";"));
};

var errorCallback = function(err) {
  console.log(err);
};

var trackPageviewSuccessCallback = function(){
  td.fetchUserSegments({
    audienceToken: ['YOUR_PERSONALIZATON_API_TOKEN_1', 'YOUR_PERSONALIZATON_API_TOKEN_2'],
    keys: {
      key_column_1: 'someValue',
      key_column_2: 'someOtherValue',
    }
  }, successCallback, errorCallback)
};

td.trackPageview([YOUR_TABLE_NAME], trackPageviewSuccessCallback);
</script>

Step 4: Confirmation

Now you can access to your website, and verify that the desired content is shown for you.


Last modified: Mar 22 2018 01:30:03 UTC

If this article is incorrect or outdated, or omits critical information, let us know. For all other issues, access our support channels.