Search code examples
variablesopencarttracking

Google Conversion Tracking for OpenCart


I have a serious problem here with the Conversion tracking code of Google. I've searched everywhere to no avail. I need to run this script on my Success page of OpenCart version 1.5.1.3.

<!-- Google Code for Sales Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 994251914;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "ifQwCN7LqQQQiqmM2gM";
var google_conversion_value = Total_Cost_Variable <--HERE IS THE PROBLEM
/* ]]> */

The problem is that I can't find the variable that shows the Total Cost of the purchased items in the Success page. Please, any help would be really appreciated!


Solution

  • This isn't something that is readily available. You will need to extract the total cost from the order in the checkout/success.php controller file, then add it to the data to be passed to the view. This is because the success controller clears the cart before the success page, making the values non existent from that point forwards