Skip to main content
November 17, 2017
Question

Pull Domain Out of Email Address

  • November 17, 2017
  • 2 replies
  • 6629 views

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

SanfordWhiteman
Level 10
November 17, 2017

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

Erin_Van_Leer
Level 2
February 2, 2018

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?

SanfordWhiteman
Level 10
February 2, 2018

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.

Jay_Jiang
Level 10
April 27, 2018

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:

<?php

$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.

Jerry_Cooper1
Level 2
December 1, 2018

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

Jerry Cooper
SanfordWhiteman
Level 10
December 1, 2018

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.)