5 Replies Latest reply on Apr 26, 2018 7:18 PM by Jay Jiang

    Pull Domain Out of Email Address

    Catherine S

      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
          Sanford Whiteman

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

          1 of 1 people found this helpful
          • Re: Pull Domain Out of Email Address
            Jay Jiang

            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.