Jump to content

Analytics conversion and complete.tpl


Juanzo

Recommended Posts

I've read some threads about configuring Google AdWords / Analytics conversion tracking but I can't seem to get it done. Please bear with me if this has been explained before.

 

  1. This is the code I've used in complete.tpl to make AdWords conversion tracking. Should I do anything else?
    {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}
    <link rel="stylesheet" type="text/css" href="templates/orderforms/cart/style.css" />
    
    <p align="center" class="cartheading">{$LANG.orderconfirmation}</p>
    
    <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">{$LANG.invoicenumber}{$invoiceid}</a></p>
    {/if}
    
    {if $ispaid}
    <!-- Google Code for Contratación de Servicios Conversion Page -->
    <script language="JavaScript" type="text/javascript">
    <!--
    var google_conversion_id = XXXX;
    var google_conversion_language = "es";
    var google_conversion_format = "1";
    var google_conversion_color = "ffffff";
    var google_conversion_value = {$amount};
    var google_conversion_label = "MXB0CN-wVhDLjrr9Aw";
    //-->
    </script>
    <script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js">
    </script>
    <noscript>
    <img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/XXXXX/?value={$amount}&label=MXB0CN-wVhDLjrr9Aw&script=0"/>
    </noscript>
    {/if}
    
    <p align="center"><a href="clientarea.php">{$LANG.ordergotoclientarea}</a></p>
    


  2. At Google Analytics settings, I've placed the following URL as exact match: /clientes/order.php?step=complete.

 

Is that all or should I do something else?

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

I take it that in your real code you replaced XXXX with your actual conversion ID number?

 

The code I'm using is (NB: you must replace XXXX with your actual ID and label code!):

 

For conversion tracking:

 

<!-- Google Code for Sale Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = XXXX;
var google_conversion_language = "en_GB";
var google_conversion_format = "1";
var google_conversion_color = "ffffff";
var google_conversion_label = "XXXX";
//-->
</script>
<script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height="1" width="1" border="0" src="https://www.googleadservices.com/pagead/conversion/XXXX/?label=XXXX&script=0"/>
</noscript>

 

And below for E-commerce Analytics tracking:

{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}


<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>

 

Plus the usual Analytics code in the footer template.

Edited by Terra
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