如何将变量字段名称放入窗体程序集窗体上的隐藏字段中



我们有两个表单工具,用于在我的组织中捕获潜在客户,我正在尝试创建一个电子表格,该电子表格使用相同的公式来创建UTM参数链接,以跟踪我们使用Google Analytics的营销活动。

示例公式 =SUBSTITUTE

(IF(LEFT(G4,1(="[","--",CONCATENATE(G4,IF(ISERROR(FIND("?",G4,1((=TRUE,CONCATENATE("?"(,CONCATENATE("&"((,IF(C4=","estate="(,IF(C4=",",C4(,IF(A4=",","&utm_campaign="(,IF(A4=",",A4(,"&utm_medium=",H4,"&utm_source=",D4,IF(E4<>"-",CONCATENATE("&utm_content=",E4(,IF(E4<>"-",CONCATENATE(",$F$2(,(((," ","%20"(在我们的 Pardot 页面上,我应用了 https://jennamolby.com/how-to-use-utm-parameters-to-capture-lead-source-in-pardot/中概述的详细信息,并正确填充了这些隐藏字段。

我的麻烦在于FormAssembly表单。我可以更改上面的公式以包含 FormAssembly ID,即tfa_199替换utm_medium,这工作正常,但随后我需要我的电子表格用户知道该登录页面上正在使用哪个表单工具。有没有办法将相同的公式应用于两个表单工具,然后使用 JavaScript 填充这些隐藏字段的值?

我尝试过将Pardot JavaScript与FormAssembly标签切换为没有运气。

示例链接 https://www.tfaforms.com/4757457/?tfa_98=Test%20Estate%20X999&tfa_197=Fonzi&tfa_199=social&tfa_200=Facebook&tfa_198=Feed

// Parse the URL
function getParameterByName(name) {
name = name.replace(/[[]/, "\[").replace(/[]]/, "\]");
var regex = new RegExp("[\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/+/g, " "));
}
// Give the URL parameters variable names
var source = getParameterByName('utm_source');
var medium = getParameterByName('utm_medium');
var campaign = getParameterByName('utm_campaign');
var term = getParameterByName('utm_term');
var content = getParameterByName('utm_content');
var estate = getParameterByName('estate');
// Put the variable names into the hidden fields in the form"
document.querySelector("tfa_200 input").value = source;
document.querySelector("tfa_199 input").value = medium;
document.querySelector("tfa_197  input").value = campaign;
document.querySelector("tfa_201  input").value = term;
document.querySelector("tfa_201  input").value = content;
document.querySelector("tfa_196  input").value = estate;
</script> 

The ideal result is regardless of whether the form is a Pardot or FormAssembly the hidden fields populate the same using the same formula.

你试过这个吗:

https://stackblitz.com/edit/js-hgrwkn

如果您的输入字段具有 ID:

<input type="text" id="utm_source" name="tfa_200"/>

和您的隐藏字段:

<input type="hidden" id="tfa_200" name="utm_source"/>

然后:

<script>
document.getElementById('tfa_200').value = 
document.getElementById('utm_source').name;
</script>

然后document.getElementById('tfa_200').name将包含utm_source.

最新更新