2017-03-02 65 views
0

我们想要一种方式来跟踪通过未通过Marketo发送的邮件来点击PDF链接的潜在客户。我们也不希望打开PDF文件(要求我们的客户填写表格)来访问文件。在谈到支持和淘汰Marketo四维支持网站之后,我了解到(我认为)实现这一目标的唯一方法是制作REST API调用,并尝试从PC上的cookie文件获取主要信息(将会访问我们的PDF是已知的客户,而不是普通大众)我不是专家的编码员,所以我从我的研究中修补了这段代码,足以说它不工作,任何帮助将不胜感激。根据Marketo Cookie提供的潜在客户信息自动填充Marketo表单字段

<script src="//xxx.marketo.com/js/forms2/js/forms2.min.js"></script> 
<form id="mktoForm_2244" style="display:none"></form> 
<script>MktoForms2.loadForm("//xxx.marketo.com", "xxx-xxx-xxx", 2244);</script> 

<script> 
MktoForms2.whenReady(function(form) { 

    //OnSuccess is optional - only if you need to make client-side decisions about Thank You URL 
    form.onSuccess(function(vals, tyURL) { 
    location.href = 'http://www.1234.com/rs/xxx-xxx-123/images/somepdffile.pdf'; 
    return false; 
    }); 

    //Get LEAD info from cookie 
    var mktoGet = new XMLHttpRequest(); 
    mktoGet.open("GET", "https://xxx-xxx-xxx.mktorest.com/rest/v1/leads.json?filterType=cookie&filterValues=<cookie>&fields=email,firstName,lastName&access_token=<token>", false); 
    mktoGet.send(); 

    //set the first result as local variable 
    var mktoLeadFields = mktoLead.result[0]; 

    //map your results from REST call to the corresponding field name on the form 
    var prefillFields = { 
      "Email" : mktoLeadFields.email, 
      "FirstName" : mktoLeadFields.firstName, 
      "LastName" : mktoLeadFields.lastName 
      }; 

    //pass our prefillFields objects into the form.vals method to fill our fields 
    form.vals(prefillFields); 
    }); 
    //Submit the form 
    form.submit(); 
}); 
</script> 

p.s.我替换和值,一旦我粘贴在浏览器中的链接,我得到了一个成功的结果。

回答

0

您将无法以这种方式使用REST API,因为它要求您每次都生成一个新的访问令牌,并且更麻烦,将它公开在客户端。 我能想到的唯一选择是使用重定向链接到marketo登陆页面。 您将创建一个空着陆页并插入以下代码,该代码将简单重定向到您的PDF。

<script>location.href = 'http://www.1234.com/rs/xxx-xxx 123/images/somepdffile.pdf';</script> 

这项活动将被记录在活动日志已知线索和

0
<script type="text/javascript"> 
    document.write(unescape("%3Cscript src='//munchkin.marketo.net/munchkin-beta.js' type='text/javascript'%3E%3C/script%3E")); 
</script> 
<script> 
    Munchkin.init('xxx-xxx-xxx'); 
</script> 
<script> 
if (!Array.prototype.indexOf) { 
    Array.prototype.indexOf = function(obj, start) { 
     for (var i = (start || 0), j = this.length; i < j; i++) { 
      if (this[i] === obj) { return i; } 
     } 
     return -1; 
    } 
} 
    (function(redirectTarget){ 
    var allowedOrigins = [ 
     'https://aaa.bbb.com', 
     'https://aaa.com', 
     'http://bbb.ccc.com', 
     ], // which domains are allowed for redirection 
     redirectMs = 3500, // how long before redirecting 
     progressMs = 500, // how long between updates of the "progress meter" 
     progressChar = '.', // progress character 
     errNoAsset = 'URL not found.', // message when no asset in hash 
     errInvalidAsset = 'URL not allowed.', // when asset not our domain 
     progress = setInterval(function(){ 
      if (redirectTarget) { 
      document.body.insertAdjacentHTML('beforeend',progressChar); 
      } else { 
      clearInterval(progress), clearTimeout(redirect);   
      document.body.insertAdjacentHTML('beforeend',errNoAsset);   
      } 
     }, progressMs), 
     redirect = setTimeout(function(){   
      var redirectLoc = document.createElement('a'); 
      redirectLoc.href = redirectTarget; 
      redirectLoc.origin = redirectLoc.origin || 
       [redirectLoc.protocol, 
        '//', 
        redirectLoc.hostname, 
        ['http:','http:80','https:','https:443'] 
        .indexOf(redirectLoc.protocol+redirectLoc.port) != -1 
         ? '' 
         : ':' + redirectLoc.port 
       ].join(''); 

      clearInterval(progress); 
      if (allowedOrigins.indexOf(redirectLoc.origin) != -1) {    
       document.location.href = redirectTarget; 
      } else { 
       document.body.insertAdjacentHTML('beforeend',errInvalidAsset);     
      } 
     }, redirectMs); 
    })(document.location.hash.substring(1)); 
</script> 
+0

任何人都知道如何将一个条件添加到代码后,删除任何东西“?”在一个链接? – Rayyis

相关问题