Copy fields from a “lead template” to other leads using a Data Transfer Page and Call Webhook

SanfordWhiteman
Level 10 - Community Moderator
Level 10 - Community Moderator
SanfordWhiteman_0-1710183857605.png

 

Ever wanted to copy a bunch of fields from a “lead template” to new leads on creation? Or “broadcast” field values from a primary lead to a group of related leads, say all from the same company?

 

(Just say yes, it’ll make me feel better about developing this method.☺)

 

It’s all possible with a Data Transfer Page (DTP). A DTP forms the backbone of my popular SimpleDTO library — the JS solution for cross-origin form pre-fill. In that case, the DTP is fetched by the browser. You can also read a DTP entirely from the server side using a webhook to transfer values across leads!

 

A key difference is that with SimpleDTO, the DTP is an HTML document with an “island” of valid XML inside it; that island then gets parsed as an XML doc and then the values are used to pre-fill. In contrast, when used as a lead template, the DTP as a whole is parsed as an XML doc, which webhooks can parse for Response Mappings.

 

Make a DTP that’s valid XML

We can make a Marketo Guided LP Template output well-formed XML 1.0✱✱ with a cool trick.

 

Create a GLPT

Start with a minimal DTP template with a few sample fields:

<!DOCTYPE html>
<html>
  <head>
  {{my.HTML Comment Begin}}
    <meta charset="utf-8">
    <title></title>
  </head>
  {{my.HTML Comment End}}
  <body>
    <fields>
      <status>{{lead.Lead Status}}</status>
      <orgtype>{{lead.Organization Type}}</orgtype>
      <company>{{company.Company Name}}</company>
    </fields>
  </body>
</html>

 

Create an LP based on that GLPT

Create an LP based on that template in Marketing Activities. Make sure Personalized URL is checked. Give the LP a long, unguessable name — a GUID, ideally – because it’s only used internally:

SanfordWhiteman_8-1710139247093.png

 

Add the XMLifying tokens

Note the LP needs to be in MA as opposed to Design Studio because it includes these two Text {{my.tokens}}:

SanfordWhiteman_9-1710139267794.png

 

{{my.HTML Comment Begin}} simply has a closing </head> and opening comment:

</head><!--

{{my.HTML Comment End}} contains just the closing comment:

-->

 

The tokens do the work of keeping the automatically injected favicon <link> tags out of the final markup:

<!DOCTYPE html>
<html>
  <head>
  </head><!--
    <meta charset="utf-8"><meta name="robots" content="noindex, nofollow">
    <title></title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" href="/favicon.ico" type="image/x-icon">
    <style>.mktoGen.mktoImg {display:inline-block; line-height:0;}</style>
  </head>
  -->
  <body id="bodyId">
    <fields>
      <status>Open</status>
      <orgtype>Regional</orgtype>
      <company>Generic US Company</company>
    </fields>
    <script src="..."></script>
    <script>...</script>
    <script src="..."></script>
  </body>
</html>

 

Those <link>s wouldn’t be valid XML because they don’t have a closing </link>. Conversely, if they had a closing tag, they’d be invalid HTML, though browsers would ignore that in practice! Anyway, we just comment out the whole <head> and make our own empty one. Good to go.

 

Create a custom field for a lead’s (most recent) template

You can have an unlimited number of lead templates, and each one — for reasons that will become very clear soon! — has a unique code. So create a new field to hold that value:

SanfordWhiteman_10-1710139371896.png

 

Note a single lead record can have multiple templates applied over time. You’d first set the Lead Template Unique Code and apply that template by running the associated Smart Campaign. Later, you can change Lead Template Unique Code and request/trigger the SC again.

 

Create a webhook that fetches the DTP pURL

We’re almost there. Now, create a webhook that fetches the approved LP, appending the Lead Template Unique Code to the URL so it’s actually fetching the Personalized URL:

SanfordWhiteman_11-1710139411150.png

 

Note the .html extension is (per usual) omitted from the LP URL when making the pURL:

https://pages.example.com/template-e58708fa-a046-4dff-af34-b715306b59ae/{{lead.Lead Template Unique Code}}

 

The Response Type is XML. In Response Mappings, map each of the XML elements to the corresponding Marketo field:

SanfordWhiteman_12-1710139442036.png

 

Later, you can add any field in your instance, these 3 are just examples.

 

Create a lead template

Maybe you’re already putting it together: each “lead template” is just a standard Marketo lead record, identified by its Marketo Unique Code!

 

Create a new lead template in the database and manage its interesting fields like you would any other lead:

SanfordWhiteman_13-1710139463057.png

 

Apply the lead template

Now, set another lead’s Lead Template Unique Code and run them through the webhook...

SanfordWhiteman_14-1710139485722.png

 

… and you’ll see them pick up all the mapped fields:

SanfordWhiteman_15-1710139494313.png

 

Naturally, you can use Block Field Updates to stop the template from affecting certain fields.

 

I’m sure you’ll think of cool stuff to do with this. Beyond triggering on new leads, one ad hoc use case is replicating a bunch of person-level (not account-level) fields across all the records at a given company.

 

NOTES

✱ Why XML? Because {{lead.tokens}} are only properly encoded for an HTML or XML context.

✱✱ XML 1.0 because in 1.1 the <?xml declaration becomes required, and we don’t have that.

387
0