Can a Webhook be used to dynamically add JavaScript to a landing page?

Anonymous
Not applicable

Can a Webhook be used to dynamically add JavaScript to a landing page?

I'm trying to figure out how to allow a Marketo customer to be able to call a service to grab some JavaScript and have it automatically added to a landing page hosted by Marketo. Ideas?

6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

Re: Can a Webhook be used to dynamically add JavaScript to a landing page?

"Grab some JavaScript" -- what do you mean by that?

A Marketo-hosted LP is subject to no more (and no less) restriction than any other webpage as far as including outside content.

That is, you can call cross-domain services if they feel like letting you do so (via CORS proper or via JSONP).

What exactly is the the "service" and is it really grabbing JavaScript, or JSON?

Anonymous
Not applicable

Re: Can a Webhook be used to dynamically add JavaScript to a landing page?

We were originally told that using a Webhook could leverage calling an external service. We would create a service that would pull the JavaScript snippet, but I wasn't sure if that were to work, how we would be able to insert it into the HTLM.

SanfordWhiteman
Level 10 - Community Moderator

Re: Can a Webhook be used to dynamically add JavaScript to a landing page?

Well, a webhook can update fields stored on a Lead or Company.

It's very, very unlikely that this how you should shove data into your webpages (though, in theory, it would work, since you can use tokens on an LP).  Is it always different data per lead?  Is there some specific reason you can't have JS in the LP itself call out to the external service?  It's much more efficient to call out from the client (JS) for the primary reason that you only have to do this for leads that actually hit your page.  If you use a webhook you have to run every potential lead through the 'hook even if only a handful of them end up visiting. That's very bad for your instance's performance.

Anonymous
Not applicable

Re: Can a Webhook be used to dynamically add JavaScript to a landing page?

When the landing page gets triggered from the email, the JS will call out and we will dynamically rewrite the CTN on the page when it gets rendered. The complication is that the JS is specific per account because that is how we will attribute a call to an account. I guess I'm trying to find a best solution for Marketo customers to get the JS snippet into the Landing Page.

SanfordWhiteman
Level 10 - Community Moderator

Re: Can a Webhook be used to dynamically add JavaScript to a landing page?

That will not work.  Webhooks do not run while a Landing Page is being rendered (I shudder at the performance destruction if they did!).

Webhooks can be triggered to run in response to lead events.  They will always run after-the-fact and there is no guarantee for when they will complete (so no, you also can't run a webhook in response to a Clicked Email event and expect the lead to be updated by the time they get to the Landing Page).

If the JS is specific per account you must run the JS within the webpage, using a {{token}} to identify the lead.  If it's as simple as a script inclusion you can just put

     <SCRIPT type="text/javascript" src="http://externalservice.example.com/user={{Lead.Email Address}}"></SCRIPT>

If you have more questions about this you can contact me via https://purechat.me/sanford.  It might be better to have a phone call since I feel like you're unclear about the front-end/back-end relationship.

Anonymous
Not applicable

Re: Can a Webhook be used to dynamically add JavaScript to a landing page?

Thank you! I am really new to Marketo and would appreciate some additional clarity.