Re: How to Read and update custom field in Marketo

JayNGravel
Level 1

How to Read and update custom field in Marketo

I need to build a voting system in Marketo. Similar to this page

Here I don't want any form submission to take place. I just want to update some specific custom fields with vote count on clicking voting button.

Here is my plan and you can suggest if any better execution plan if you have

 

Step 1 - Since we are not taking email address, we will create one dummy email address and update all voting count to this contacts custom field. Please note this is purely for voting count and nothing else.

 

Step 2 - read the custom field values before submitting the new value using below rest API

https://Marketo-end-point-url/rest/v1/leads.json?filterType=id&filterValues=<dummy_email_address_id>&access_token=&fields=Customfield1, Customfield2, Customfield3

 

Here I am not sure whether we can show access_token in landing page source code or in jQuery files. It might lead to data hack. open for suggestions.

 

Step 3 - After reading the Customfield data, increment the count by "+1" and update it using rest api.


You can suggest if there is an another way to do this. 

 

Thank you in advance.

5 REPLIES 5
Darshil_Shah1
Level 10 - Community Advisor

Re: How to Read and update custom field in Marketo

You can create a poll asset for this, if you'd would like to count the votes. It's probably an add-on feature, so you may not have it if you haven't purchased it. 

 


Here I am not sure whether we can show access_token in landing page source code or in jQuery files. It might lead to data hack. open for suggestions.

 


It isn't a good idea to use REST APIs directly on the client side at all, IMO you should consider using webhook for updating the count on the custom fields instead.

 

Best,
Darshil
JayNGravel
Level 1

Re: How to Read and update custom field in Marketo

Thank you for looking into this. 

I did use POLL for this but it asks social sharing login every time when I vote which I dont want to use. 
I will look into Webhook. Thank you for the right direction. 

SanfordWhiteman
Level 10 - Community Moderator

Re: How to Read and update custom field in Marketo


I will look into Webhook. Thank you for the right direction. 


Well, a webhook needs to run in the context of a lead.

 

Which means you need an activity that's logged under a known lead: the mkt_tok-enized pageview and/or Munchkin session needs to be associated with a lead. You could perhaps use a custom Munchkin visitWebPage call.

 

There's another somewhat hacky way to do this completely anonymously by having a couple of different LPs. Then load one of them (in an IFRAME or even as an <img src> as JS doesn't matter here) depending on the person's choice. Look at the view counts in Marketo and that'll tell you how many people requested the URL. 

SanfordWhiteman
Level 10 - Community Moderator

Re: How to Read and update custom field in Marketo

You must not call the REST API directly from JavaScript under any circumstances. It's probably the biggest technical NO in all of Marketo.

 

(Note even if you were to use the REST API properly, that is, server-to-server, there would be no reason to use a dummy lead when a Program {{my.token}} could serve the same role.)

 

JayNGravel
Level 1

Re: How to Read and update custom field in Marketo

@SanfordWhiteman 
Thank you for the reply. I will drop the REST API process idea and looking into Webhook as @Darshil_Shah1  suggested. 

If there is any better way to read and update the count in custom field, please suggest.