Jump to content

google conversion script at the end of complete.tpl instead in if


thomask

Recommended Posts

Welcome.

 

We use web20cart as order template and we use google adwords. We have google conversion script at the end of the complete.tpl file but there's small problem with amount of order.

 

/ We'd like to use conversion when pro-forma invoice is generated, not when client makes payment so we don't want to have this code between {ifpad} at the middle of complete.tpl file /

 

Our complete.tpl file looks like this: (in this case conversion works correct with stable value=1)

 

<link rel="stylesheet" type="text/css" href="templates/orderforms/web20cart/style.css" />
<h2>{$LANG.orderconfirmation}</h2>
<p>{$LANG.orderreceived}</p>
<div class="cartbox">
 <p align="center"><strong>{$LANG.ordernumberis} {$ordernumber}</strong></p>
</div>
<p>{$LANG.orderfinalinstructions}</p>
{if $invoiceid && !$ispaid}
<div class="errorbox">{$LANG.ordercompletebutnotpaid}</div>
<p align="center"><a href="viewinvoice.php?id={$invoiceid}" target="_blank">Faktura pro forma {$invoiceid}</a></p>
{/if}

{if $ispaid}
<!-- Enter any HTML code which needs to be displayed once a user has completed the checkout of their order here - for example conversion tracking and affiliate tracking scripts -->
{/if}
<p align="center"><a href="clientarea.php">{$LANG.ordergotoclientarea}</a></p>

{literal}
<!-- Google Code for Zakup Conversion Page -->
<script type="text/javascript">
<!--
var google_conversion_id = XXXXXXXXX;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "XXXXXXXXXXXXXX";
var google_conversion_value = 1;
//-->
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
{/literal}

 

The problem is when we'd like to use variable $amount, whole script just doesn't work.

We tried with {php}{/php} {html}{/html} where the var $amount is, nothing helps.

Any idea how to solve this problem?

 

<link rel="stylesheet" type="text/css" href="templates/orderforms/web20cart/style.css" />
<h2>{$LANG.orderconfirmation}</h2>
<p>{$LANG.orderreceived}</p>
<div class="cartbox">
 <p align="center"><strong>{$LANG.ordernumberis} {$ordernumber}</strong></p>
</div>
<p>{$LANG.orderfinalinstructions}</p>
{if $invoiceid && !$ispaid}
<div class="errorbox">{$LANG.ordercompletebutnotpaid}</div>
<p align="center"><a href="viewinvoice.php?id={$invoiceid}" target="_blank">Faktura pro forma {$invoiceid}</a></p>
{/if}

{if $ispaid}
<!-- Enter any HTML code which needs to be displayed once a user has completed the checkout of their order here - for example conversion tracking and affiliate tracking scripts -->
{/if}
<p align="center"><a href="clientarea.php">{$LANG.ordergotoclientarea}</a></p>

{literal}
<!-- Google Code for Zakup Conversion Page -->
<script type="text/javascript">
<!--
var google_conversion_id = XXXXXXXX;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "XXXXXXXXXXX";
var google_conversion_value = 1;
if $amount {
   google_conversion_value = {$amount};
}
//-->
</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/XXXXXXXXXXX/?value={$amount}&label=XXXXXXXXXXXX&guid=ON&script=0"/>
</div>
</noscript>
{/literal}

Link to comment
Share on other sites

  • 3 months later...

Hi thomask

 

I'm in early days with whmcs but my coding experience tells me that your reference to $amount in the middle of the JavaScript is not going to work. JavaScript code referencing php variable?

 

if $amount {
   google_conversion_value = {$amount};
}

 

Something like this was suggested by Matt:

 

{php}
$orderid = $this->get_template_vars('orderid');
$result = select_query("tblorders","amount",array("id"=>$orderid));
$data = mysql_fetch_array($result);
$amount = $data["amount"];
$this->assign('amount',$amount);
{/php}

 

This will get the order value from the database then you can reference amount in your JavaScript code.

 

Or use php inside {php} tags to reference the php variable $amount.

 

Matt's code referenced from thread here:

http://forum.whmcs.com/showthread.php?t=9002&highlight=analytics thread #14

 

Hope this helps :)

Link to comment
Share on other sites

or maybe you were trying to reference the smarty/template variable, not php, sorry. :oops:

 

I think then you need to come out of {literal} tag for the variable reference to work. Something like this:

if ({/literal}$amount{literal}) {
 google_conversion_value = {/literal}$amount{literal};
}

 

Maybe someone with more whmcs experience can confirm this for us both? :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated