Associating URL Slug with Product | Community
Skip to main content
Liz_Smith
Level 2
March 12, 2019
Question

Associating URL Slug with Product

  • March 12, 2019
  • 1 reply
  • 2880 views

I have forms setup on each product page on my website. When someone fills out the form, I receive an email. I want the email to include what product they were looking at. How do I translate the product ID in the URL slug to the associated product ID in my CRM system?

For example, if I fill out a form on the page www.test.com/123, and 123 is known as product 1 in my CRM, I want to receive an email trigger from Marketo that says "New Form filled out for "Product 1."

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

1 reply

SanfordWhiteman
Level 10
March 12, 2019

What you're calling the URL slug is the pathname (or part of the pathname), a standard value available in the browser.

You'd have to use JavaScript to parse that value out of the URL, then write it to a hidden field on the form using addHiddenFields.

A greatly simplified example:

MktoForms2.whenReady(function(form){

form.addHiddenFields({

LastProductPage : document.location.pathname.replace(/^\//,"")

});

});

Also pretty sure this has been asked (and answered by me!) before, if you search.

Liz_Smith
Liz_SmithAuthor
Level 2
March 13, 2019

Hi Stanford,

Thank you for the quick response. The issue is not getting that value, but rather translating it from a code to the product name in our CRM system. Is this something we can do without getting into the website code? We only have access to the forms form the Marketo side.

Thank you!

SanfordWhiteman
Level 10
March 13, 2019

Actually you do need JS like the above to get the code, or you'll have nothing to look up on the server side!

The translation from the code to the friendlier name can be done in one of 2 ways:

  1. Use a webhook to call a lookup service (API) offered by your website, if one exists.
  2. Maintain a list of the code-to-name mappings in a Velocity token. Look up in that mapping table to output only the friendly name in your alert.

Obviously if you have no way of looking up the product names, whether via API or a periodic export/paste, there wouldn't be any way to accomplish this... Marketo can't read from the private db used on your site.