我最近安装了一个脚本,为我的网站访问者创建了一个Google __utmz cookie,并设置了所有字段。以下是对它的看法。
<script>
function get_campaign_info()
{
var utma = get_utm_value(document.cookie, '__utma=', ';');
var utmb = get_utm_value(document.cookie, '__utmb=', ';');
var utmc = get_utm_value(document.cookie, '__utmc=', ';');
var utmz = get_utm_value(document.cookie, '__utmz=', ';');
source = get_utm_value(utmz, 'utmcsr=', '|');
medium = get_utm_value(utmz, 'utmcmd=', '|');
term = get_utm_value(utmz, 'utmctr=', '|');
content = get_utm_value(utmz, 'utmcct=', '|');
campaign = get_utm_value(utmz, 'utmccn=', '|');
gclid = get_utm_value(utmz, 'utmgclid=', '|');
session_count = get_session_count(utma);
pageview_count = get_pageview_count(utmb, utmc);
if (gclid !="-") {
source = 'google';
medium = 'cpc';
}
}
</script>
浏览我的cookies我可以看到它正在被创建。例如,有点像: “47664550.1486736628.2.2.utmcsr = website.com | utmccn =(引荐)”
我发现的问题是我无法弄清楚如何将这些字段(例如Campaign Medium)推送到我网站上的隐藏表单字段。下面是我的典型Marketo表单如何使用用户数据创建隐藏字段。
MktoForms2.whenReady(function(form){
ga(function(){
form.addHiddenFields({
GA_User_ID__c : ga.getByName('gtm1').get('userId')
});
});
有没有人知道如何将媒体,会话等推送到隐藏字段?感谢您的任何建议或只是为了阅读!如果有帮助,我一直在运行测试的页面是powerreviews.com/form-test
答案 0 :(得分:0)
对于Marketo表单,您应该使用Marketo Form API。转到this page并向下滚动到隐藏字段示例。
如果URL发生变化,以下是示例代码:
MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function (form) {
// Set values for the hidden fields, "userIsAwesome" and "enrollDate"
// Note that these fields were configured in the form editor as hidden fields already
form.vals({"userIsAwesome":"true", "enrollDate":"2014-01-01"});
});