Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Google Checkout - How to add tracking info.

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 06-16-2008, 10:51 AM
  BunnyburyBaby's Avatar 
BunnyburyBaby BunnyburyBaby is offline
 

Advanced Member
  
Join Date: Nov 2007
Location: Los Angeles
Posts: 32
 

Default Google Checkout - How to add tracking info.

Hello,

I am trying to integrate my Commision Junction program. I have the Image Pixel tracking working great, but they need to track sales done via Google Checkout.

After looking into it I found that you can add a tracking beacon to the final page at google checkout:

http://code.google.com/apis/checkout/developer/checkout_pixel_tracking.html

In gcheckout.php, there is a section:

Code:
<?xml version="1.0" encoding="UTF-8"?> <checkout-shopping-cart xmlns="http://checkout.google.com/schema/2"> <shopping-cart> <merchant-private-data> <merchant-note>$unique_id</merchant-note> </merchant-private-data> <items> $items </items> </shopping-cart> <checkout-flow-support> <merchant-checkout-flow-support> <platform-id>429557754554554</platform-id> <request-buyer-phone-number>true</request-buyer-phone-number> $shipping_xml $merchant_calculations_xml <edit-cart-url>$xcart_catalogs[customer]/cart.php</edit-cart-url> <continue-shopping-url>$current_location/payment/ps_gcheckout_return.php?mode=continue&#x26;skey=$unique_id</continue-shopping-url> $tax_tables </merchant-checkout-flow-support> </checkout-flow-support> </checkout-shopping-cart>


My question is how do I pass the parameterized-url? It needs to contain the same information contained in the trackin pixel used in order_message.tpl. That snippit is:

Code:
{foreach from=$orders item="order"}<img src="https://www.bunnyburybaby.com/u?CID=24145&OID={$order.order.orderid}&TYPE=5000{foreach from=$order.products item=product name=pr}&ITEM{$smarty.foreach.pr.iteration}={$product.productcode}&AMT{$smarty.foreach.pr.iteration}={$product.price}&QTY{$smarty.foreach.pr.iteration}={$product.amount}{/foreach}&CURRENCY=USD&METHOD=IMG" height="1" width="20">{/foreach}

so that the xml outputs like this:


<parameterized-urls>
<parameterized-url url="https://www.bunnyburybaby.com/u?CID=241145&OID=11561&TYPE=5000&ITEM1=CL-LC-GREEN&AMT1=39.95&QTY1=1&ITEM2=HS-INDIE&AMT2=35.27&QTY2=1&ITEM3=BO-601&AMT3=14.95&QTY3=1&ITEM4=GIFTWRAP&AMT4=7.50&QTY 4=1&CURRENCY=USD&METHOD=IMG" />
</parameterized-urls>
</merchant-checkout-flow-support>
</checkout-flow-support>
</checkout-shopping-cart>

I need to call all the product and order information in gcheckout.php and format it to output the xml above. Any ideas on how to do this?

Thanks folks!
Bunnyburybaby
__________________
X-Cart Version 4.1.8
Reply With Quote
  #2  
Old 06-16-2008, 10:54 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Google Checkout - How to add tracking info.

Moving to Template Editing as this is not related an X-Cart add-on.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 06-18-2008, 07:07 AM
  BunnyburyBaby's Avatar 
BunnyburyBaby BunnyburyBaby is offline
 

Advanced Member
  
Join Date: Nov 2007
Location: Los Angeles
Posts: 32
 

Default Re: Google Checkout - How to add tracking info.

UPDATE:

I opened a ticket with support, they pointed out that I cant send the order data to google because it has not been created yet. I cant send the order ID in the url.

I need to remove the first foreach, modify the second foreach to grab the product data from the cart instead of order.

I then need to add a parameterized-urls tag:

<parameters> <url-parameter name="orderID" type="order-id"/>
<url-parameter name="totalCost" type="order-total"/>
<url-parameter name="taxes" type="tax-amount"/>
<url-parameter name="shipping" type="shipping-amount"/>
</parameters>

inside the <parameterized-urls> area.

I am making progress, but I still dont know how to call the product data in the gcheckout.php. Any thoughts?


Once I have my solution, I will post it as I understand that CJ tracking and google checkout have been a problem for many folks. This will also allow me to integrate other tracking information from my various networks like shopping.com, shopzilla and others.

Thanks!
__________________
X-Cart Version 4.1.8
Reply With Quote
  #4  
Old 06-19-2008, 02:33 PM
  BunnyburyBaby's Avatar 
BunnyburyBaby BunnyburyBaby is offline
 

Advanced Member
  
Join Date: Nov 2007
Location: Los Angeles
Posts: 32
 

Default Re: Google Checkout - How to add tracking info.

UPDATE:

I have had some progress, but I still need some help with looping the product info in the url.

I have it sending the information I want to google, but it only sends the data for the first product. If I add more than one product, only the first product data shows in the URL.

I have attached the XML that is sent to google, you can see that there are three items in the cart, but the CJ tracking url only passes data for the first product. This is because I dont know how to loop the product data in the xml element. (I am not a programmer)

I have also attached a copy of my gcheckout.php that contains the code.

The url sent to google checkout looks like this:

https://www.emjcd.com/u?CID=24145&amp;TYPE=5000&amp;ITEM1=GB-ORSW2-SET&amp;AMT1=84.95&amp;QTY1=1&amp;CURRENCY=USD&amp ;METHOD=IMG

I need it to look like this:

https://www.emjcd.com/u?CID=24145&amp;TYPE=5000&amp;ITEM1=GB-ORSW2-SET&amp;AMT1=84.95&amp;QTY1=1&amp;ITEM2=ITEM2SKU&a mp;AMT2=ITEM2PRICE&amp;QTY2=ITEM2QTY&amp;ITEM3=ITE M3SKU&amp;AMT3=ITEM3PRICE&amp;QTY3=ITEM3QTY&amp;CU RRENCY=USD&amp;METHOD=IMG

There needs to be something like the {$smarty.foreach.pr.iteration} I like I used in my order_message.tpl to attach a number to the ITEM AMT QTY parts, then it needs to loop for each item in the cart. I have no idea how to loop the data inside an XML element because I am not that familiar with PHP. I have modified the gcheckout.php to include an additional foreach statement to generate the xml, this snippit of code is:

First I added this code inside the foreach used in the item area...

$_qty = func_google_encode($_product['amount']);
$_sku = func_google_encode($_product['productcode']);
$_prc = func_google_encode($_product['display_price']);
$num = $num + 1;

Then just above where the XML is put together I added this code:

$purls =<<<OUT
<parameterized-url
url="https://www.emjcd.com/u?CID=24145&amp;TYPE=5000&amp;ITEM1=$_sku&amp;AMT1 =$_prc&amp;QTY1=$_qty&amp;CURRENCY=USD&amp;METHOD= IMG">
<parameters>
<url-parameter name="orderID" type="order-id"/>
</parameters>
</parameterized-url>
OUT;

Then the code is put together using the $purls:

$cart_xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">
<shopping-cart>
<merchant-private-data>
<merchant-note>$unique_id</merchant-note>
</merchant-private-data>
<items>
$items
</items>
</shopping-cart>
<checkout-flow-support>
<merchant-checkout-flow-support>
<platform-id>429557754455455</platform-id>
<request-buyer-phone-number>true</request-buyer-phone-number>
$shipping_xml
$merchant_calculations_xml
<edit-cart-url>$xcart_catalogs[customer]/cart.php</edit-cart-url>
<continue-shopping-url>$current_location/payment/ps_gcheckout_return.php?mode=continue&#x26;skey=$u nique_id</continue-shopping-url>
$tax_tables
<parameterized-urls>
$purls
<parameterized-url
url="https://www.googleadservices.com/pagead/conversion/107074459/?label=purchase&amp;script=0">
</parameterized-url>
</parameterized-urls>
</merchant-checkout-flow-support>
</checkout-flow-support>
</checkout-shopping-cart>
XML;

The second googleadservices parameterized url is a static url, the first of several I am going to add once I solve this first problem.

I hope this helps us solve the problem. So close...

Looking forward to your responses...

BunnyburyBaby
Attached Files
File Type: php gcheckout-sample.php (16.7 KB, 47 views)
File Type: txt gcheckout-sampleXML.txt (5.2 KB, 52 views)
__________________
X-Cart Version 4.1.8
Reply With Quote
  #5  
Old 06-27-2008, 12:22 PM
  BunnyburyBaby's Avatar 
BunnyburyBaby BunnyburyBaby is offline
 

Advanced Member
  
Join Date: Nov 2007
Location: Los Angeles
Posts: 32
 

Default Re: Google Checkout - How to add tracking info.

Ok folks, 80 points later... I have the solution.

Here are the sections dealing with tracking multiple products:

First, add to the foreach item loop in gcheckout.php:

BEFORE:
Code:
$length = 160; if (strlen($_descr) > $length) { $_descr = substr($_descr, 0, $length); } $_title = func_google_encode($_product['product']); $_descr = func_google_encode($_descr); if (!empty($_product['taxes'])) { .....


AFTER:
Code:
$length = 160; if (strlen($_descr) > $length) { $_descr = substr($_descr, 0, $length); } $_title = func_google_encode($_product['product']); $_descr = func_google_encode($_descr); $_qty = func_google_encode($_product['amount']); $_sku = func_google_encode($_product['productcode']); $_prc = func_google_encode($_product['display_price']); $_counter++; $_tracking_xml .= "&amp;ITEM$_counter=$_sku&amp;AMT$_counter=$_prc&amp;QTY$_counter=$_qty&amp;CURRENCY=USD"; if (!empty($_product['taxes'])) {

Then add a new XML section:
BEFORE:
Code:
$shipping_xml = "<shipping-methods>\n$shipping_xml\n\t\t\t</shipping-methods>\n"; } } $cart_xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <checkout-shopping-cart xmlns="http://checkout.google.com/schema/2"> <shopping-cart> <merchant-private-data> <merchant-note>$unique_id</merchant-note> </merchant-private-data> <items> $items </items> </shopping-cart> <checkout-flow-support> <merchant-checkout-flow-support> <platform-id>429557754556845</platform-id> <request-buyer-phone-number>true</request-buyer-phone-number> $shipping_xml $merchant_calculations_xml <edit-cart-url>$xcart_catalogs[customer]/cart.php</edit-cart-url> <continue-shopping-url>$current_location/payment/ps_gcheckout_return.php?mode=continue&#x26;skey=$unique_id</continue-shopping-url> $tax_tables </merchant-checkout-flow-support> </checkout-flow-support> </checkout-shopping-cart> XML;

AFTER:
Code:
$shipping_xml = "<shipping-methods>\n$shipping_xml\n\t\t\t</shipping-methods>\n"; } } $purls =<<<OUT <parameterized-url url="https://www.emjcd.com/u?CID=5000&amp;TYPE=214213$_tracking_xml&amp;METHOD=IMG"> <parameters> <url-parameter name="orderID" type="order-id"/> </parameters> </parameterized-url> OUT; $cart_xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <checkout-shopping-cart xmlns="http://checkout.google.com/schema/2"> <shopping-cart> <merchant-private-data> <merchant-note>$unique_id</merchant-note> </merchant-private-data> <items> $items </items> </shopping-cart> <checkout-flow-support> <merchant-checkout-flow-support> <platform-id>429557754556845</platform-id> <request-buyer-phone-number>true</request-buyer-phone-number> $shipping_xml $merchant_calculations_xml <edit-cart-url>$xcart_catalogs[customer]/cart.php</edit-cart-url> <continue-shopping-url>$current_location/payment/ps_gcheckout_return.php?mode=continue&#x26;skey=$unique_id</continue-shopping-url> $tax_tables <parameterized-urls> $purls <parameterized-url url="https://www.googleadservices.com/pagead/...label=purchase&amp;script=0"> </parameterized-url> </parameterized-urls> </merchant-checkout-flow-support> </checkout-flow-support> </checkout-shopping-cart> XML;

This solution allows me to put in many different urls for tracking from various sources. All I need to do is add a new <parameterized-url> entry for each item I need tracked. If my tracking requires the products as well then I add it to the $purls section.

A few things left to fix:

First: I would like the display_price to be the discounted price after coupons or discounts. This involves creating an if statement, if discount do this, otherwise display regular price. The code eludes me.

Second: I have yet to figure out how to get the Marketing Manager module by Firetank to track orders through google checkout. Right now when I track sales the orders placed through GC do not show up at all in the Marketing Manager. If anyone knows please post it here.

Thanks folks!

Bunnyburybaby.com
__________________
X-Cart Version 4.1.8
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 05:33 AM.

   

 
X-Cart forums © 2001-2020