![]() |
Add product data to Google Analytics tracking |
Post Reply ![]() |
Author | ||||||||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() Posted: 27-February-2014 at 7:31pm |
|||||||
This may be included in a recent update, as we're still on 4.2b. On orderCompleteTracking.asp, you can find this comment:
We already had some order data being tracked in GA (Google Analytics), but it was basically just the Order ID and total price. However, wanted to take full advantage of GA's tracking functions, and track tax, shipping charges, geographical data, and product information. This actually turned out to be easier than I expected. We modified our orderCompleteTracking like so:
All of the new information for the _addTrans was already on the orderComplete.asp page, so it was just a matter of finding the variables (this may not work for countries that use VAT instead of Tax). For the product information, I had to make a couple changes to orderComplete.asp: At the beginning of the file I defined a new array to hold ordered product data (i don't know if it needs to go in a certain place, but i put it under all of the other dim statements as that seemed to make sense):
Then I set up this block of code to create an array of dictionary items holding all of the product data. I also had to pull the category from the database as it is not included in orderComplete.asp by default:
I put that block of code right after this stuff:
...and right before this stuff...
So the whole section of the page should look like:
You'll see something in there about defaultCategory. We noticed there was no good way to set a "default" product category for breadcrumbs, canonicals, and other stuff. I just added a new defaultCategory column to categories_products and changed the modifyProduct.asp page on the dashboard to allow us to set a default category for each product. This helped as, by default, productcart would use the first category to which the product was assigned for the breadcrumbs, which can sometimes be problematic. However, you can probably replace that whole "Get default category" with a simple query to just pull the category name of the first assigned category for the product:
I'm not sure if this will be useful for anyone else, but I figured I'd post it here as it was a fairly simple modification. If anyone notices any errors / vulnerabilities in the code please let me know. Edited by Brett - 01-March-2014 at 12:31am |
||||||||
![]() |
||||||||
Guests ![]() Guest ![]() |
![]() ![]() ![]() ![]() ![]() |
|||||||
Nice work, Brett!
Very gracious of you to share this. I'm curious what insights you plan to glean from this data, though. Mind sharing that side of it?
|
||||||||
![]() |
||||||||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() |
|||||||
I'm not sure how to do this in Analytics yet, but I want to be able to tell where sales for certain products are coming from, as far as keywords, referring sites, and what pages they went through to get to the product.
|
||||||||
![]() |
||||||||
Guests ![]() Guest ![]() |
![]() ![]() ![]() ![]() ![]() |
|||||||
Thanks, Brett. I think I could see how that could be valuable data perhaps vis a vis targeting ads. Excellent first step in the project. If you don't have the data, you can't mine it, right? I'd like to think more about it.
Meanwhile, a couple of observations: 1) You might want to remove your Google account id from the code above (using the edit post option). Probably no harm in having your domain in there too, but I'll leave that up to you. 2) Having seen that in your posted code I peeped your site to see if I could quickly glean how this data might be interesting for you .... and I noticed your coupons page. I've been giving a lot of thought in the back of my busy mind about how to leverage exactly such a page for social media and other marketing angles. Incidentally, you might find that our Discount Codes before Checkout extension would play perfectly with your objective here.
|
||||||||
![]() |
||||||||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() |
|||||||
Whoops! Thanks for the heads up on GA account. I'll get in touch with you regarding coupons page. We love it, and probably 80% of our customers use the coupons. Though maybe they'd still buy and not use coupons if we didn't have them, who knows lol.
Discount codes before checkout is something we've been wanting for a long time. I will definitely ask you about this (hopefully) tomorrow. |
||||||||
![]() |
||||||||
whizzinpc ![]() Newbie ![]() ![]() Joined: 17-January-2006 Location: California Status: Offline Points: 20 |
![]() ![]() ![]() ![]() ![]() |
|||||||
Thanks for sharing Brett. This is very useful.
|
||||||||
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |