我正在使用Avada的模板(http://theme-fusion.com/avada/contact/)并使用他们的联系页面。每当有人提交一个成功的表单时,该页面将重新加载一个额外的"警报"已填充成功消息的框。如果可能,我希望在此警报框中嵌入Google转化像素,而不必将用户发送到全新的页面。创建警报框的代码是
<?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
<?php echo do_shortcode( '[alert type="success" accent_color="" background_color="" border_size="1px" icon="" box_shadow="yes" animation_type="0" animation_direction="down" animation_speed="0.1" class="" id=""]' . __( 'Thank you', 'Avada' ) . ' <strong>' . $name . '</strong> ' . __( 'for contacting us! Your email was successfully sent!', 'Avada' ) . '[/alert]' ); ?>
<br />
<?php } ?>
生成
<div class="fusion-alert alert success alert-dismissable alert-success alert-shadow">
<button type="button" class="close toggle-alert" data-dismiss="alert" aria-hidden="true">×</button>
<span class="alert-icon">
<i class="fa fa-lg fa-check-circle"></i>
</span>
Thank you <strong>Test</strong> for contacting us! Your email was successfully sent!</div>
<br />
</div>
希望嵌入的代码看起来像这样
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "1";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/1/?label=1&guid=ON&script=0"/>
</div>
</noscript>
非常感谢任何帮助
答案 0 :(得分:0)
由于每行都有开启和关闭的php标签,你可以简单地将html代码粘贴在两个php块之间(但是在&#34; if&#34;块之后)。您可以选择仅使用noscript块中的图像标记(仍将跟踪转换)。
<?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
// just the noscript image tag, alternatively paste the whole code here
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/1/?label=1&guid=ON&script=0"/>
<?php
echo do_shortcode( '[alert type="success" accent_color="" background_color="" border_size="1px" icon="" box_shadow="yes" animation_type="0" animation_direction="down" animation_speed="0.1" class="" id=""]' . __( 'Thank you', 'Avada' ) . ' <strong>' . $name . '</strong> ' . __( 'for contacting us! Your email was successfully sent!', 'Avada' ) . '[/alert]' ); ?>
<br />
<?php } ?>