selvagsz
selvagsz

Reputation: 3872

Updating Lead Info in marketo

Initially, I associate the lead when the user signs up to our app on a 14 days trial period.

function associateMarketoLead() {
 if (window.marketoKey)) {
  if (typeof Munchkin !== 'undefined') {
   if ('function' === typeof Munchkin.munchkinFunction) {
    let leadAttributes = {
      Email: user.email,
      accountId: accountId,
      LeadSource: 'Web'
    };

    Munchkin.munchkinFunction('associateLead', leadAttributes, marketoKey);
   }
  }
 }
}

We use marketo to send email campaigns at the end of 14-days trial. But, for certain leads, we extend the trial period and so we want to update the lead's database with trial extended date. How can I do that ? I tried the following, but it doesn't work

function notifyMarketoOnTrialExtension(accountId, trialExtendedDate) {
 if (window.marketoKey) {
  if (typeof Munchkin !== 'undefined') {
   if ('function' === typeof Munchkin.munchkinFunction) {
    var leadAttributes = {
      Email: user.email,
      accountId: accountId,
      trialExtendedDate: trialExtendedDate
    };

    Munchkin.munchkinFunction('associateLead', leadAttributes, window.marketoKey);
   }
  }
 }
}

Any suggestions ?

Upvotes: 0

Views: 440

Answers (1)

Alejo Fernandez
Alejo Fernandez

Reputation: 21

This small snippet shows you how to invoke associateLead with the correct key (third parameter), which is an SHA1 hash of your private key concatenated with the email of the lead you are trying to associate. In your example you are just sending the private key as third parameter.

I used this library for calculating the SHA1 hash //cdnjs.cloudflare.com/ajax/libs/jsSHA/2.0.2/sha1.js

var email = '[email protected]';
var shaObj = new jsSHA('SHA-1', 'TEXT');
shaObj.update('<your-munchkin-private-key-goes-here>' + email);
var hash = shaObj.getHash('HEX');
Munchkin.init('<your-munchkin-identifier-goes-here>');
Munchkin.munchkinFunction('associateLead', { 'Email': email }, hash);

Hope it helps.

Alejo.

Upvotes: 1

Related Questions