我从来没有在网站上使用Google Adwords,所以如果我对'lingo'不正确,请随时纠正我 .
我正在开设一个网站,该网站上有一个Google AdWord广告系列的目标网页 . 在此页面上有一个表单,在处理后,会将您带到另一个页面,说“感谢您的请求......” . 我删除了这个并用PHP和Javascript重写它以防止页面刷新或重定向 .
我遇到的问题是,在'thank you'页面上,Google代码略有不同,并在加载页面时执行 . My question is, how can I re-execute the conversion code with different variables without re-loading the page? Is there a Google script for this?
Will removing the script tag, and then placing it again re-execute the script?
这是我目前拥有的代码(在表单提交之前):
<!-- Google Code for Company Remarketing List Remarketing List -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 000000;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "abcdefg";
var google_conversion_value = 0;
/* ]]> */
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"></script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/000000/?label=abcdefg&guid=ON&script=0"/>
</div>
</noscript>
表单提交后需要更改的内容是:
var google_conversion_id = 111111;
var google_conversion_label = "gfedcba";
"http://www.googleadservices.com/pagead/conversion/gfedcba/?label=111111&guid=ON&script=0
Changing the variables is easy! The hard part is getting the script to re-execute with the new variables.
任何帮助非常感谢!
UPDATE
发布的答案here可能解决了这个问题,但是,我想知道如何使用本答案中提到的变量提交其他变量 . 他们非常自我解释,但我不能确定他们是对的!
In addition, does anyone know where on Google I can actually see instructions for this?
1 回答
您不能只重新执行脚本的原因是 - 您可能已经注意到 - 它使用的是
document.write
,在文档加载后不应该调用它 .一个可能的解决方案就是像你提到的那样自己解雇GIF请求 . 如果你真的想重新执行脚本,可以重定向
document.write
.以下是如何完成此操作的一般概念 - 此片段将放置在您将新内容重新加载到页面中的某个位置 . 它假定您使用jQuery并已将新页面内容加载到
$newContent
并标记了所有需要在使用class="ajax-exec"
重新加载时执行的脚本标记 . 它的作用是直接执行内联脚本并使用jQuery的$.ajax
函数和dataType: script
. 然后等待直到所有外部脚本都已执行,并将重定向的输出附加到隐藏的div
.这适用于我们,但没有保修(: