Pull Domain Out of Email Address

Not applicable

Pull Domain Out of Email Address

I put leads into Marketo from many different sources, so a user's website domain isn't always automatically populated by Marketo. Does anyone know a way to build a campaign or script in Marketo so that any new lead added has their email address domain populate the `Website` custom field?

Example: Ideally if I add mark@facebook.com to Marketo, then his website would automatically be set as facebook.com.

Thanks for your help!


Re: Pull Domain Out of Email Address

If not set at lead creation, this can only be done via webhook (callout from a flow).

Re: Pull Domain Out of Email Address

How do you set this at lead creation? Or do you just mean, if Marketo fails to set this at lead creation, I'll need to use a webhook?

Re: Pull Domain Out of Email Address

Meaning if the source (web form, outside application, etc.) doesn't put the domain in a separate field at the start, you have to call a webhook. Marketo itself won't do this internally.

On a Marketo form, you can use a little JS to populate a separate hidden field with the domain.

But it's going to be harder to get an outside app -- whose initial author might be long gone -- to add this functionality, even though it's simple in any language.

Re: Pull Domain Out of Email Address

Okay that makes sense. Thanks for your help!

Level 7

Re: Pull Domain Out of Email Address

We use webhooks to php files to transform Marketo data like standardising phone numbers and States. If you want to go down this path, you'll need a server to host the php file, which most people with a website should already have.

Basic code for what you want is:


$em  = $_POST['email'];

$em = array_filter(explode("@", $em));

$response = '{"domain":"'.$em[1].'"}';

echo $response;


In Marketo you'll need create a webhook where URL is the link to the php file, Template is email={{lead.Email Address}} and response type is JSON

You'll also then need to edit response mappings for the webhook where response attribute is domain and Marketo field is Website

You can also add security by adding custom headers to your Marketo webhook like PHP_AUTH_USER and PHP_AUTH_PW but I'd recommend getting a php developer to edit the php code for you.

Re: Pull Domain Out of Email Address

I put the PHP file in our design center. Why won't that work?

Re: Pull Domain Out of Email Address

There's no support for running user-supplied PHP templates in Marketo.

Jay's speaking about a potential webhook implementation on your own server.  It can of course be written in any language: Java, JavaScript, PHP, Ruby, etc. (there are services that allow you pass code to them for execution, so you don't have to run the service at all).

(P.S. The proper logic is to split on the @ character, check if the count is > 1, and take the last item, not the second item.)

Re: Pull Domain Out of Email Address

It works with outside server,but cannot get the response to post to Marketo. What are we doing wrong here


Re: Pull Domain Out of Email Address

You have to show the Activity Log Detail for the Call Webhook step.