Get Lead

Last Updated: 06 Sep 2018

The Get Lead process refers to the retrieving of lead data from Marketo.

In order for Squiz Matrix to retrieve data, a Marketo Bridge must be created and the Marketo Settings configured. For more information, refer to the Marketo Bridge chapter in this manual.

The Get Lead API can be enabled in the Get Lead API Settings section of the Marketo Bridge.

The following example code will retrieve the lead data of the current user and dump this data to the JS console.

Please note that this example assumes that the jQuery JavaScript library is available in the code and that the Marketo Cookie is already set for the current user. Refer to the Marketo Cookie chapter for more information.

If a Marketo Cookie is not available, the Email attribute must be provided as lead key. For more information, refer to the Verifying a User's Email Address chapter.

$.get("./?a=1234?action=getLead", function(data){
}); //Note: 1234 is the asset ID of the Marketo Bridge asset.

The Allowed Attributes setting on the Marketo Bridge allows you to specify the attributes to retrieve with the Get Lead API. This is useful is you only want to retrieve specific lead data from a user, rather than all associated data.

If no cache is required, an extra 'nocache' url parameter can be added to the code, like so:

$.get("./?a=1234?action=getLead&nocache", function(data){

Please note that the Get Lead API has a default daily limit of 10,000 requests, imposed by Marketo. This daily limit can be extended to 10,000 unique user sessions with the use of default caching.

Get Lead Global Keywords

As an alternative to the Get Lead API, lead data can also be retrieved from Marketo using global keyword replacements.

The following keywords are available for retrieving lead data:

  • %globals_marketo_lead:1234% : will output the current user's lead data in a json array format.
  • %globals_marketo_lead_id:1234% : will output the lead ID.
  • %globals_marketo_lead_email:1234% : will output the lead email.
  • %globals_marketo_lead_attribute_X:1234% : will output the attribute as specified (e.g. FirstName).

Where 1234 is the asset ID of the Marketo Brige.

If no cache is required:

  • %globals_marketo_lead_nocache_id:1234%
  • %globals_marketo_lead_nocache_email:1234%
  • %globals_marketo_lead_nocache_attribute_X:1234%

The output of these global keywords will be sanitised by escaping special characters, in order to prevent basic cross-site scripting. You may, however, need to undertake further steps, such as using keyword modifiers, to ensure the usage of these keywords is secure.

Get Lead Caching

By default, lead data retrieved via the Get Lead API or the associated global keyword replacements is cached for a user's session. This ensures that multiple API calls or keywords will print lead data efficiently.A Sync Lead call, via either the Sync Lead API or the associated form submission action, will recache the lead data for the current user. Similarly, a nocache Get Lead API call or global keyword will also recache this lead data.

If a shorter caching time is required, it can be specified in the Lead Caching setting on the Details screen of the Marketo Bridge.