Detecting the language used in a Marketo form fillout.

Marketo doesn't have a language detection feature, but luckily the Google Translate Language Detection API is really easy to call as a Marketo webhook.

Webhook setup

You set up a webhook that POSTs JSON to https://translation.googleapis.com/language/translate/v2/detect. In the querystring you add ?key= and your key. The payload is a simple JSON object with one or more q (for “query”) properties:

In this case I'm passing the {{lead.Last Name}} token. You can pass any {{Lead.,}} {{Company.}}, or {{My.}} token you want.

Here's an example response viewed in Postman:

Then you set a simple response mapping to a custom field if you want:

The response mapping is actually optional. It allows you to permanently store the detected language on the lead (which you might use for other purposes, if you're not only deleting bot-generated leads). If you're just deleting, or moving leads into a list for a last check before deletion, you don't need to store the language on the lead: you can use the Webhook is Called trigger instead, as noted below.

Link the parameters with the webhook

Now that you've got the webhook set up with a valid API key, you'll need a typical sequence of batch+trigger campaigns to call the 'hook for your “interesting leads.” As always, be conservative with your webhook calls and don't waste resources when there won't be any interesting data. Constrain your campaigns by people who have Filled Out Form, for one thing, and also (since you're probably dealing with a storm of bots after a certain point) constrain by timestamp.

If you've used webhooks before, you already know how it goes. Ready a Trigger SC with the Campaign is Requested trigger:

… whose Flow calls the webhook:

… and have a Batch SC call the Trigger SC for the leads in question:

… and, finally, process results with Webhook is Called:

In the last trigger, I'm matching the response string against

"language":"zh-
because I want to catch both "language": "zh-TW" (Chinese-Taiwan) and "language": "zh-CN" (Chinese-China).

And also note (discovered this only recently with a client) that even though the literal JSON response is

"language": "zh-TW"
Marketo removes the spaces (this is a bug IMO, as the response should be considered a literal string) so you have to match on:

"language":"zh-TW"