Ubercart Variables List

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Hello Ryan / Lyle / Anybody,
I'm looking for a variables list for Ubercart like those found for the page.tpl.php files, see http://drupal.org/node/11812 for what I mean.

I need these to be able to tag my site with Omniture web analytics.

Thanks,
Clint

Posts: 203
Joined: 09/06/2007

would be nice to know the structure of $items, $order, etc, "i know.."

Posts: 5269
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Any of those variables apply. Also, are you looking for something like the order object when an order is checked out?

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Specifically what I am looking for are the ubercart specific variables:

-Purchase event (the variable that says Order Complete)
-The Product variable something like uc_products->$product
-The Sale Price
-The QTY ordered
-The variable that says (Product X added to your shopping cart) after clicking Add to Cart on the Product View Page
-The product SKU
-State variable used during checkout
-Zip code variable used during checkout
-Order ID
-And if anyone knows the variables for Search Keyword and # of search results

Basically what needs to happen is certain javascript variables in my analytics code need to be populated with the ubercart values, see below for example of what I mean, I've used the Drupal $title variable to populate s.pageName.

This is the function I'm using to populate s.pageName, just below

<?php
    $checkcrumb
= strip_tags($breadcrumb);
        if (
$title != "") {
            if (
$checkcrumb == "Home") {
               
$mytitle = "Site Docs";
            }
            if ((
$title == "Checkout") || ($title == "Review Order") || ($title =="Shopping Cart") || ($title =="Order Complete")) {
               
$mytitle = "Checkout Process";
            }
            else {
           
$mytitle = str_replace('','',strip_tags($breadcrumb));
            }
           
$scpagename = "$mytitle &raquo; $title";
        }
        else {
           
$scpagename = "Home";
        }
?>

s.pageName="

<?php
echo $scpagename
?>
"
s.prop1="
<?php
echo $searchstring
?>
"

s.products=";
<?php
$sku
?>
;
<?php
$qty
?>
;
<?php
$price
?>
"

Any help is greatly appreciated.

Posts: 5269
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Every order has an order ID, and when that order is loaded, most of the other data you're looking for gets filled in. In fact, anything related to orders or products on order will be there. Now, regarding when an order is purchased, that would be when hook_order() gets called with the submit $op.

Regarding the message for items added to the cart... that's actually a Drupal message and it happens in the function uc_cart_add_item().

A lot of these event related ones just aren't variables, but you can hook into most of them using a custom module with the hooks we provide.

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

I use Omniture as well for our analytics. I took the google analytics module and gutted it for Omniture. I like what you've done here for setting s.pagename and would like to fold it in to what I have. The cart markup task on this weeks agenda if you would like to collaborate on this?

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

I know that you are primarily concerned with populating s.products right now, I'm not there yet. We will be running multiple report suites so I was playing with the admin settings. Here is what I identified as being settable: (again, expanding on Mikes work)

Usage
=====
In the settings page enter your Omniture Report Suite ID.

You will also need to define what user roles should be tracked.
Simply tick the roles you would like to monitor.

All pages will now have the required JavaScript added to the
HTML footer can confirm this by viewing the page source from
your browser.

'admin/' pages are automatically ignored by Omniture

The following settings will be controllable from the admin:

Track Download Links
Track External Links
Track Inline Stats
Link Leave Query String

Check off extensions of Download File Types

Enter Internal Filters
Enter linkTrackVars
Enter LinkTrackEvents

Enter your campaign variable to tag SEO query links with:

Enter your visitorNameSpace variable.

Enter any plugins you will be using.

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Steve,
I've been formulating the same agenda. I've also been talking with Greg Knaddison at drupal.org who is working on a module for Omniture, find it here: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/omniture/

We should interface with him as he has already done some work on this.

Thanks for your input.
Clint

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

I have posted a couple of issues with Greg's module and am working on it as well now. As of yet it doesn't do much more than insert the raw .js script tags into the footer of your pages.

We still need to do a ubercart componant that will manage the stages of the cart.

On pageview: s.events="prodView" and s.products=";$product_name ($model no)"

On first add_to_cart: s.events="scOpen,scAdd" and s.products=";$product_name[0] ($model no),;$product_name[1] ($model_no)"

On nth add_to_cart: s.events="scAdd" and s.products=";$product_name ($model no)),;$product_name[1] ($model_no)"

on checkout: s.events="scCheckout" and s.products=";$product_name ($model no)),;$product_name[1] ($model_no)"

on confirmation page: s.events="purchase" and s.products=";$product_name ($model no));$qty;$total_line_cost,;$product_name[1] ($model_no);$qty1;$total_line_cost1"

In addition, we want to serialize the purchase event with something like:
s.events="purchase:$orderno"

Does this all jive with your thinking on how the uc_omniture part should work?

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Jives!

We also need to grab these at the checkout confirmation page
s.state="$order($state)"
s.zip="$order($zip)"
s.purchaseID="$order($order no)"

An this for whenever someone clicks view cart
s.events="scView"

Some of the items in your (Blessed_Steve) post like the scAdd and s.products could be trigged as an onclick event with the Add to cart button. Just food for thought.

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

Insurrectus,

Will it work for you if, for this first version we assume that when an item is added to the cart, the user is directed to the shopping cart page? furture versions would have to deal with the case where items are put in the cart but either displayed in a block or not fully acknowleged until view cart is pressed.

I would like to avoid the complexity of direct server calls to omniture in this first version and stick will embedded js in html format. forcing the user to view the cart insures we can count every add to cart event without intermediate server calls. does this make sense?

Steve

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

How can I tell in my uc_sitecatalyst_add_to_cart hook if a customer is adding an item to a new shopping cart vs. an existing one?

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Steve,
You make a lot of sense, and having the user redirected to shopping cart is what a lot of other shopping cart systems are like (Amazon.com, Buy.com, etc).

Clint

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Omniture has a plug-in called getCartOpen which identifies the first time a product is added to
the cart (first scAdd). The Cart Open event can be used to compare carts initialized to carts completed (orders).

I'm checking in to it now to see if this will work.

Clint

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

I'll wait to hear back from you on the openCart question. meantime, I am wondering how to mark up the review your order page. it exists in the cart so we take over from Greggles still but Site Catalyst does not have a predefined event for this stage of the checkout process.

Right now I am leaning toward appending "checkout review" to s.pagename

Do you have anything better for this?

Steve

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

I think that you've got it right to just use the checkout review pagename.

Also, in the checkout page have you setup an event to track how far through the panes a visitor has progressed? I was think that on each tab the same event could be used.

For example:
xxxx@xxxx.com >> Next ([Checkout]Email Address) gets set as an event
1234 e maple st, anytown, ut 84660 ([Checkout]Shipping Address) gets set to the same event and replaces the previous event

OPENCART FUNCTION (I don't know if it's what we need or not):
s.getCartOpen=new Function("c",""
+"var s=this,t=new Date,e=s.events?s.events:'',i=0;"

// 30 minute timestamp
+"t.setTime(t.getTime()+1800000);"

+"if(s.c_r(c)||e.indexOf('scOpen')>-1){"
// cookie exists or scOpen set, write/extend cookie time
+"if(!s.c_w(c,1,t)){s.c_w(c,1,0)}"
+"}else{"
+"if(e.indexOf('scAdd')>-1){"
// scAdd set without scOpen, write cookie
+"if(s.c_w(c,1,t)){i=1}"
+"else if(s.c_w(c,1,0)){i=1}"
+"}"
+"}"

// add scOpen if needed
+"if(i){e=e+',scOpen'}"
+"return e"
);

SET IN THIS MANNER:
s.events=s.getCartOpen("s_scOpen");

Hope this is helpful.

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Or we could just bypass the review order page all together. There has been some discussion about this here at Ubercart.org.

How I look at the review order page is as just one more opportunity for a visitor to have buyers remorse and not buy!

I don't know if the UberDudes are working on this option or not...Ryan, Lyle, any thoughts?

Clint

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

Just a quick update on where I am. I have a SiteCatalyst module that will do a rough markup of the ubercart process now... view cart through confirmation page. In order to get it integrated I started working with Greg more actively on the Drupal project. He is adding in a Site Catalyst variable update hook so that the main module will create the fully formed JS that gets embedded in a page. It will check with our Ubercart module to see about setting the success eVars, scAdd, scCheckout etc. prior to putting the code into the resulting page. Anyway he stuff is fully viewable, as you know, at the link posted above. I will get you a copy of my stuff as soon as I get it cleaned up a bit and the hook_eVars works.

Steve

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

End of day update. The Ubercart module is on hold while we work out a hook in greggles Drupal module that will allow the Ubercart module to update the cart specific variables in the overall markup.

I'll post a link as soon as that is done. Have a good weekend.

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Hey Steve,
Thanks for all your work on this. I'm excited to get testing!

Clint

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

So I have a lot of plates spinning and managed to get distracted with other dev issues. Sorry to hold up the works here.

Greggles setup this omniture module http://drupal.org/project/omniture which, based on the Google analytics module, inserts the omniture js into the footer of pages.

I posted a patch which is under consideration with him. It will implemt a hook to allow modules to modify the eVars that are being sent to omniture.

Having accomplished that, I created a uc_sitecatalyst module that specifically marks up the ubercart pages. You can get the omniture module at the link above.. be sure to snag the patchs since there is no "official" release of that module yet.

Then you can grab my uc_sitecatalyst at: http://www.beyond-print.com/uc_sitecatalyst.tar.gz

I have no doubt that it needs a lot more work, but I wanted to post it so that it can start gathering moss!

Ubercat for President! Smiling
Steve

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

The function call bug on line 79 has been fixed and the tarball has been updated.

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Steve,
Looks really good! A couple of suggestions/corrections:

Suggestion 1
s.products should not include the product name, only the sku, this is an omniture recommendation, the best way to include product names is to use SiteCatalyst classifications using SAINT to match-up SKU with product name.

This way if a seller changes the product name they will not get duplicate products in their SiteCatalyst data.

Example:
s.product=;Spiffy Widget (SKU1234)
or
s.product=;SKU1234

Because the SKU is not likely to change and the product name is...it is recommended to only use the SKU.

Suggestion 2
s.events is set to scAdd on the checkout page, it needs to be scCheckout
s.events=ProdView doesn't seem to be set on the product node page

Suggestion 3
On the "Order Complete" page the SiteCatalyst code seems to short circuit and the image request is not sent to Omniture, therefore no data is being sent. As such I could not verify if s.events=purchase was working.

I'll look through the code some more this evening and see if I can find why the Order Complete page short circuits.

Thanks for all your work.

Clint

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Changed Line 128 to: $sproducts=';'.$node->model;

Changed Line 146 to: $sproducts .= $product->model;

Changed Line 153 to: $sproducts .= $product->model . ",";

Changed Line 164 to: $sproducts .= $product->model . ";".

Steve let me know if this makes sense.

Cheers on the great work,
Clint

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Steve, just realized another issue:

events=scAdd
products=;HAM-SS-Cocoa

Once set, stays set...on view cart and checkout pages.

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

hi, I just posed the question http://drupal.org/node/185835 at drupal asking where to manage the development process of the ubercart mod to the drupal omniture module. Not to repeat myself totally but issue tracker is setup over there for the overall module. It might make sense to move the discussion into that forum? I can post updates here?

Ryan et. al. how would you ideally like to see contributors manage ongoing module discussions?

Posts: 5269
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Hey Steve... I'd say whatever works best for you. I'd like for folks to be able to find Ubercart.org who haven't heard of Drupal and be able to find info on all of Ubercart's capabilities, but that doesn't mean everything needs to be hosted here or only here. I'm considering posting some of our modules to Drupal.org simply to get more exposure in the modules list. Sticking out tongue

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

Thanks Ryan. I didn't realize until after I posted that you have issue tracking for other contributions in your tracker. I'm just lazy that way apparently.

Anyway, I am thinking that it makes sense for the ubercart spawn to live here and the parent module at Drupal.org to point to it. That is cleaner and lends itself to other efforts branching.. osCom and ZenC for instance, neither of which I would be trying to maintain. Still, I'll see what Greggles comes back with in that thread before committing. I've def got other work to do!

Posts: 138
Joined: 08/22/2007
Spreading the word - Ubercart for president.

Steve,
Just figured out where the issue was on the Order Success page (Line 181):

foreach($SiteCat_Vars as $SCvar => $SCval) {
$script .= var . $SCvar . ' = "' . $SCval . '"
';
}

Needs to be:

foreach($SiteCat_Vars as $SCvar => $SCval) {
$script .= $SCvar . ' = "' . $SCval . '"
';
}