Google Analytics beta testing

by tobi - jaded Pixel - 09:41PM, Nov 10, 2006

OK Integrating google analytics properly into shopify is proving harder then I thought.

The biggest problem is the somewhat cryptic admin interface of GA and the fact that it often takes 24 hours for anything to show up.

I thought i’d go ahead and post what i have got so far. Some of you here are real GA experts and I hope that we can puzzle out together how to get GA to work really well. Once we figured it out i’ll add some nice guides or even direct GA support to the Shopify admin but in the meantime we do it manually, as of today all the required tools should be in place.

  1. Sign-up for a GA account.
  2. Setup the stats tracking as per instructions on the screen.
  3. the script tag they provide should go in your theme.liquid right before </head> near the top. Yes they tell you to put it near the bottom but it makes no difference unless half of your page is generated by javascript.
  4. Note down the GA identifier which will appear in the javascript code you have to paste in your shopify theme. It should look something like this: UA-82702-4
  5. Now back in the overview screen you should see the address of your store. Click the Edit link next to it.
  6. Click the Edit link in the top right in the Main Website Profile Information section.
  7. Set E-Commerce Website to yes.
  8. Adjust your currency settings.
  9. Back in shopify head over to the preferences screen for checkout & payments
  10. At the bottom in the additional content & scripts section paste the following:

<div style="display:none;">
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>

<form name="utmform">
<textarea id="utmtrans">
UTM:T|{{order_name}}||{{total_price|money_without_currency}}|{{tax_price|money_without_currency}}|{{shipping_price|money_without_currency}}|{{shipping_address.city}}|{{shipping_address.province}}|{{shipping_address.country}}
{% for line in line_items %}
UTM:I|{{order_name}}|{{line.sku}}|{{line.title}}||{{line.price|money_without_currency}}|{{line.quantity}}
{% endfor %}
</textarea>
</form>

<script type="text/javascript">
_uacct="UA-XXXXX-X";_udn="{{shop.domain}}";urchinTracker();__utmSetTrans(); 
</script>
</div>

Important: You have to replace the _uacct parameter with the GA identifier which you noted down earlier.

This should be all you need for real e-commerce product tracking. Lets hope this works. Any feedback is highly appreciated!

---

Tobias Lütke
Shopify – Founder, CEO

Last edited 05:44PM, Jan 03, 2007

hypersigil

Member

10:10PM, Nov 10, 2006

Tobi, I have implemented this and will update on its status tomorrow.

I still don’t understand how to set up the goal tracking for the checkout page on Analytics, though.

I currently only have one goal set—tracking which people add to cart. This lets me see which Adwords and inbound links are worth me spending time and money on—inbound links from YouTube so far have been giving me a full 100% add to cart ratio, for instance—so I’ll be ramping up advertising over there. But I want to add a second “goal” which will track what people complete a purchase. Analytics asks for the URL of the page that users hit when they do the goal (the thank you page, in this case)—what should I put in there? I suspect it would have something to do with the “head” match options at the bottom of the “Add new goal” page on Analytics, but I’m not sure.

danW

Shopify Advisor

10:11PM, Nov 10, 2006

get this when trying to save above code to checkout area of admin

undefined method `create!’ for nil:NilClass

tobi

jaded Pixel

10:33PM, Nov 10, 2006

Er sorry. Try again.

---

Tobias Lütke
Shopify – Founder, CEO

danW

Shopify Advisor

11:59PM, Nov 10, 2006

Ok, got the code in and well sit back and see how it does.

Thanks for getting this started.

Buster McLeod

Member

05:42AM, Nov 11, 2006

I’ve got it all set up too. I’ll let you know how it goes. Exciting.

Christina

Miss Manners

09:41AM, Nov 11, 2006

hi Tobi – thanks for this.
I just plunked the code in, & immediately got a new section in my g.a. reports entitled “e-commerce analysis”, which makes the “your shopping cart page” show up. (ahem – in english…)
So seems to be working fine right off the bat. Of course there’s no data yet, so I’ll let you know tomorrow.

---

operation absurdist feature requests: terminated

(http://en.wikipedia.org/wiki/Absurdism)

danW

Shopify Advisor

05:03PM, Nov 11, 2006

We ran a test order yesterday evening, and so far nothing has showed up as of yet. I think this is what you mean by, ”...it often takes 24 hours for anything to show up.”

We’ll let you know what we find.

tobi

jaded Pixel

10:14PM, Nov 11, 2006

Nothing showed up here either.

It seems that paypal is not satisfied with this solution. We will have to think up something differently.

---

Tobias Lütke
Shopify – Founder, CEO

danW

Shopify Advisor

10:42PM, Nov 11, 2006

I know that data was coming back. After the test order, we were redirected to the thank you page and I checked the html code. There was data of our order showing up for the GA script to handle.

tobi

jaded Pixel

10:45PM, Nov 11, 2006

yea but it seems that GA doesn’t manage to associate this back with the right account.

GA just needs a real API so badly its not even funny.

---

Tobias Lütke
Shopify – Founder, CEO

danW

Shopify Advisor

10:57PM, Nov 11, 2006

I think I may have found the problem. From the GA docs:


Finally, the utmSetTrans function must be called after the form is submitted in order to record the transaction. 
This can be most easily accomplished through a body onLoad event within the opening <body> tag:

    <body onLoad="javascript:__utmSetTrans()">

If you don't have the ability to edit the body tag, you can call the utmSetTrans function within a separate script 
tag as long as you ensure that the function is called after the form:

    <script type="text/javascript">
    __utmSetTrans();
    < /script>

Unless you set the body onload from the backend, I didn’t see this in your example script I copy and pasted.

Should we envoke the utmSetTrans function with the javascript method?

UPDATE: Nevermind. I see your invoking utmSetTrans with javascript.

danW

Shopify Advisor

11:05PM, Nov 11, 2006

I believe the standard tracking script is missing though. since the thank page doesn’t use the stores theme.

https://www.google.com/support/analytics/bin/answer.py?answer=27203


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
  _uacct="UA-xxxx-x";
  urchinTracker();
</script>

UPDATE: WOW. I see you have this in there too. OK, I am done for the evening….....

tobi

jaded Pixel

12:03AM, Nov 12, 2006

The issue is the domain change. GA uses cookies to track users and cookies don’t survive the domain change to checkout.shopify.com. There are ways to fix this but it means that we will have to integrate GA differently.

This is really a pity. I was hoping that this would work and we would be done with the topic =)

---

Tobias Lütke
Shopify – Founder, CEO

David B

Member

10:58PM, Nov 12, 2006

OK to get the data to survive the domain change you have to add onSubmit="javascript:__utmLinkPost(this)" to your form on the cart page, like this:

<form action="/cart" method="post" onSubmit="javascript:__utmLinkPost(this)">

Then in theme.liquid add this before urchinTracker();:

  _udn="none";
  _ulink=1;

I think this should work. Or have you already tried this? By the way here’s the support article: https://www.google.com/support/analytics/bin/answer.py?answer=26915

tobi

jaded Pixel

02:18AM, Nov 13, 2006

I’m thinking i can simplify this. Maybe i can come up with a simple javascript which people could include which just puts the onsubmit handler on all the links which require it. The stupid thing is that google could do that themselves. All this parameter hackery is really just a lack of javascript skills on their part…

---

Tobias Lütke
Shopify – Founder, CEO

Valien

Member

08:45PM, Nov 13, 2006

I added GA to my site and this as well. Looks like it could be cool. I’ll report any details/findings off my store :)

~allen

---

~Allen

hypersigil

Member

05:31AM, Nov 14, 2006

Does the technique David_B posted work?

danW

Shopify Advisor

06:28PM, Nov 14, 2006

Not sure but I just updated my scripts so We’ll see.

danW

Shopify Advisor

04:44PM, Nov 15, 2006

Well. Its still not tracking sales. I did notice that it was starting to track our admin interface traffic though. I have since removed David_B’s example.

Tobi, have you come with anything yet?

tobi

jaded Pixel

10:33PM, Nov 16, 2006

I’ll revisit this soon. The Paypal IPN issue is keeping me busy right now

---

Tobias Lütke
Shopify – Founder, CEO

Kati

Member

03:22PM, Nov 21, 2006

Hi everyone,

I just came across this in the GA help area, maybe it’s the secure pages that’s preventing the proper tracking?
From http://www.google.com/support/analytics/bin/answer.py?answer=31846&;query=ssl&topic=&type= :

How can I obtain tracking code for secure pages?

If your site includes secure web pages using the HTTPS protocol, you’ll need to make sure that your tracking code is tailored for secure access. If your Website URL includes https, your tracking code will already be customized for secure pages. Otherwise, you’ll need to update this value for your profile.

To obtain Google Analytics tracking code that is tailored to secure (HTTPS) web pages:

Log in to Google Analytics
Find the profile for which you are obtaining tracking code and click Edit
In the Main Website Profile Information bar, click Edit
Edit the Website URL field by specifying https:// rather than http://
Click Save Changes
To obtain the secure tracking code, click the Check Status link above the Main Website Profile Information bar. Your tracking code will be customized for secure pages and will look like the example below:

<script src=" https://ssl.google-analytics.com/urchin.js" type="text/javascript"> 
</script> 
<script type="text/javascript"> 
_uacct = "UA-XXXXX-X"; 
urchinTracker(); 
</script>

You can add this secure code to both secure and non-secure pages of your site.

Looks to me like the only thing that’s different is the urchin javascript source URL: https://ssl.google-analytics.com/urchin.js instead of http://www.google-analytics.com/urchin.js

What do you think? I am totally swamped this week so I didn’t yet try this code… it’s just an idea.

---

Folkology – Authentic folk craft and culture from Hungary
http://www.folkology.com

DavidC

Member

02:52AM, Nov 23, 2006

I’m almost certain the SSL change is required. I believe browsers will refuse to load component files (including external javascripts) from non-https URLs when loading a page from an https URL. Once you start the checkout process, everything from there on is https.

I also believe the __utmLinkPost change pointed out by David B will be required. When using Paypal, we are moving through 3 completely separate top-level domains to complete a purchase:

1. http://yourstore.myshopify.com
2. https://checkout.shopify.com
3. https://www.paypal.com

If I’m reading the support article from David B’s post correctly, this means the __utmLinkPost method will be required. This also means that both theme.liquid & the preferences->checkout & payments->content & scripts area code will require the use of these values:

_udn="none";
_ulink=1;

What I’m not clear on is whether making these changes in theme.liquid, cart.liquid, and the checkout & payments script area is enough. Does the Shopify checkout code (which we can’t touch) also require the use of __utmLinkPost to make the tracking & conversion data carry all the way through?

tobi

jaded Pixel

03:10AM, Nov 23, 2006

The main place where the _utmLinkPost will be required is the screen which proceeds the checkout, the one where you can choose the gateway. This screen only appears if there is more then one option (or if the one option is google checkout).

Unfortunatly this means shopify will have to change for the worse. Since javascript has to be executed before the domain change to checkout.shopify.com we will have to abandon the internal redirect logic which is running right now and always show the payment checkout screen, even when there is only one option.

I’m a bit reluctant to make this change because it negatively impacts people who don’t use google analytics and who have only one gateway. I also see great value in supporting GA though so its not out of the question. I wish GA would post their API so that we can integrate easy with them without requiring any cryptic javascript or the like.

---

Tobias Lütke
Shopify – Founder, CEO

DavidC

Member

04:21AM, Nov 23, 2006

Tobi – I’m not sure I completely follow the logic as to why the __utmLinkPost JS has to be added the way you describe, but I’m sure you know what you’re talking about. You could send down to the browser a small page that simply runs a JS to to the __utmLinkPost magic & then redirect to the (single) enabled checkout option. The user may notice a screen flicker/refresh, but would not have to choose the only checkout option available.

Also, I just started messing with all of this in the last 2 or 3 hours, and I already have data showing up in my newly-created GA profile. I don’t yet see any hits recorded within the checkout.shopify.com site, but that may just be a time lag issue.

DavidC

Member

04:35AM, Nov 23, 2006

The GA cookies are now surviving the redirect to checkout.shopify.com, thanks to the use of __utmLinkPost, but there’s no urchinTracker() call in the checkout pages to let GA know the user is now in the checkout process. I think with the current solution we may be able to track final conversions with the “thank-you” page code, but will not be able to track the individual steps in the conversion funnel:

1. view cart – should be able to track, since it is on myshopify.com
2. enter address – can’t track – on checkout.shopify.com
3. select shipping method – can’t track – ditto
4. payment (multiple steps) – can’t track – on Paypal, etc.
5. thank-you – should be able to track with Tobi’s code from above

tobi

jaded Pixel

02:49PM, Nov 23, 2006

Well thank you page is the one that counts because it indicates the sale. So if thats all working then we are almost there.

---

Tobias Lütke
Shopify – Founder, CEO

DavidC

Member

04:03PM, Nov 24, 2006

What is the URL of the thank-you page? I don’t have a second Paypal account set up, so can’t easily test a full purchase. Paypal kicks me out as soon as it sees I’m trying to pay myself. (Is there an easier way around this, besides setting up a second PayPal account?)

If the thank-you page code works, we will be able to track the ultimate conversion, but not the steps in the sales funnel that are on checkout.shopify.com.

This is certainly better than no conversion tracking, but it would be very informative to know which how many abandonments are happening at each page in the checkout process. This could provide valuable information for improving conversion rates. For example, if we find that a lot of buyers are dropping out on the shipping method page, we might want to look at our shipping methods/rates.

DavidC

Member

04:16PM, Nov 26, 2006

Ok – found & configured the Bogus gateway, so now I see what the thank-you page looks like. Unfortunately, it doesn’t have a URL that is well-suited to matching in GA’s conversion funnel tracking.

As I said in the post before this one, it looks like we can track the ultimate conversion (and the monetary value of that conversion, which is important), but we can’t track any of the funnel steps leading up to that conversion. This is less than ideal, sense we may be missing important information on where the abandonments are happening.

What we need to do this is the ability to add GA tracking code snippets to all of the pages in the checkout.shopify.com flow. Tobi – any chance of adding a place in the admin pages to put this tracking code, and include that code snippet on all the checkout pages?

This seems to be a more general solution that having a place to put the GA _uacct number, but you might prefer the control offered by only allowing the administrator to enter the _uacct, and then you can conditionally include the appropriate (well-known, tested, safe) tracking code if that value is entered.

Kati

Member

04:46PM, Nov 26, 2006

Did anyone actually see any transaction reporting from the thank you page in their GA account reports?

If the transaction reporting is working, I will be fine with that, and then later on we can figure out a way to track the conversion funnel. For now I think the critical part would be to make the thank you page tracking work.

I ran a test purchase earlier this week with all the code in place, plus using the SSL version, plus putting onSubmit=”javascript:__utmLinkPost(this)” on the cart checkout button. The transaction didn’t show up in my GA report. :(

My situation is a little more complicated though, because i am using a http://shop.mydomain.com URL for my shopify store and my GA account is set up to track both my domain at http://www.mydomain.com and all subdomains, so I already have _udn=”mydomain.com”; in my tracking code. I am afraid I can’t add another _udn=”none”; parameter because it will confuse GA. Can somebody who understands how these udn things work confirm this? (I am sure I am not hte only one using a subdomain so this might be an important question.)

---

Folkology – Authentic folk craft and culture from Hungary
http://www.folkology.com

tobi

jaded Pixel

05:38PM, Nov 26, 2006

I don’t think anyone got the e-commerce tracking working yet.

Do you know the code which should appear on each step of the checkout? I’m considering to do what you said and let people just paste their _uacct number and then inject the right html on each page automatically ( in the shop and checkout both )

---

Tobias Lütke
Shopify – Founder, CEO

DavidC

Member

03:35AM, Nov 27, 2006

I have just seen the first e-commerce tracking transaction show up in my GA reports. It does work. Here’s what I have:

On the checkout & payment preferences page, in the additional content & scripts section:

<div style="display:none;">
<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"></script>

<form name="utmform">
<textarea id="utmtrans">
UTM:T|{{order_name}}||{{total_price|money_without_currency}}|{{tax_price|money_without_currency}}|{{shipping_price|money_without_currency}}|{{shipping_address.city}}|{{shipping_address.province}}|{{shipping_address.country}}
{% for line in line_items %}
UTM:I|{{order_name}}|{{line.sku}}|{{line.title}}||{{line.price|money_without_currency}}|{{line.quantity}}
{% endfor %}
</textarea>
</form>

<script type="text/javascript">
_uacct="UA-xxxxx-x"; _udn="none"; _ulink=1; urchinTracker(); __utmSetTrans(); 
</script>
</div>

in theme.liquid, I put this at the very beginning of the body tag:

<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-xxxxx-x"; _udn="none"; _ulink=1; urchinTracker();
</script>

in cart.liquid:

  <form action="/cart" method="post" id="cartform" onSubmit="javascript:__utmLinkPost(this)">
    <div class="info">

        <input type="submit" value="Continue to checkout" name="checkout" class="primary" /> &raquo;

    </div>

DavidC

Member

04:11AM, Nov 27, 2006

Tobi – I think all you have to do to get goal funnel tracking working all the way through checkout.shopify.com is to include this code on each page, with the shop owner’s _uacct value:

<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-xxxxx-x"; _udn="none"; _ulink=1; urchinTracker();
</script>

Since we already used __utmLinkPost() in cart.liquid to get us from myshop.myshopify.com over to checkout.shopify.com, I don’t think we need to use it again as long as we stay within checkout.shopify.com. Once we go external to paypal.com, google checkout, etc. we may need to use __utmLinkPost() again so the tracking values will carry forward, but that’s not a big concern compared to what’s within checkout.shopify.com.

One remaining issue would be defining the goal funnel URLs in GA.

Using the bogus gateway, I see:
view cart: http://myshop.myshopify.com/cart
choose payment method: http://myshop.myshopify.com/checkout
address entry: https://checkout.shopify.com/carts/1016/2eb13dead31e2a104d92434e1fcb9be3
shipping method & credit card entry: https://checkout.shopify.com/orders/1016/cc2ac8b88a1edf1df57a3efd45a7ad40/pay
thank-you: https://checkout.shopify.com/orders/1016/cc2ac8b88a1edf1df57a3efd45a7ad40

Using PayPal, I see:
view cart: http://myshop.myshopify.com/cart
choose payment method: http://myshop.myshopify.com/checkout
address entry: https://checkout.shopify.com/carts/1016/9dd0137444bb41ad47b417e526ebebc6
shipping method: https://checkout.shopify.com/orders/1016/5fdc117985d2b04474f531367218f723/pay
- (off to paypal, multiple steps there)
thank-you (assuming it’s the same, haven’t tested): https://checkout.shopify.com/orders/1016/cc2ac8b88a1edf1df57a3efd45a7ad40

If you only support one payment method/gateway, you wouldn’t see the choose payment method page.

I’m not sure if the GA funnel tracking’s URL matching is going to be able to match against these URLs. You might be able to differentiate the last two steps using regular expression matching, but it would be much easier if a simple head match could be used, perhaps something like this:

view cart: http://myshop.myshopify.com/cart
choose payment method: http://myshop.myshopify.com/pmtmethod
address entry: https://checkout.shopify.com/address/
shipping method & credit card entry: https://checkout.shopify.com/shipping
thank-you: https://checkout.shopify.com/thanks

Of course, additional identifying details (cart id, etc.) included in the URL past these stem values would be no problem.

danW

Shopify Advisor

06:09AM, Nov 28, 2006

Hey David. Thank you for all the investigation and time you put in and posting your findings. I installed your code this morning and its working great! We are able to get statistics on our orders now.

Just need to tie that in with the rest of analytics so we can track goals.

Thanks again.

tobi

jaded Pixel

03:36PM, Nov 29, 2006

Can funnel URLs take wildcards perchance?

---

Tobias Lütke
Shopify – Founder, CEO

DavidC

Member

03:51PM, Nov 29, 2006

For each funnel URL, you can choose to use a regular expression match, a head match, or an exact match. Given the current checkout URLs, I think we could use an RE match to pick out the ”/pay” on the end of the shipping method selection URL & differentiate it from the thank-you URL. It looks like we’d be okay with a head match on the others.

chulee

Member

03:25PM, Dec 01, 2006

I tried it and it’s kinda working. Only one thing, I had 3 orders yesterday but it only shows “one” on the GA.

Does anybody have any idea why?

---

http://www.shopmodi.com
design gifts + modish home accessories

Foreheadkiss

Member

06:44PM, Dec 01, 2006

I’m sorry, but I’m not a coder. Is there any updates on exactly what code we should use to get this working? We use Google Analytics already but not for conversions. We use Authorize.net for a gateway. It would be great if one of you brilliant people could tell me how to make this stuff work on our site.

hypersigil

Member

09:35PM, Dec 01, 2006

So any confirmation yet that this is working properly yet? Can I just implement what David wrote?

DavidC

Member

02:32AM, Dec 02, 2006

Why not try it & let us know? My store’s not yet open for business, so all I’m seeing is my handful of test transactions, using the Bogus gateway. It appears to be working as far as I can tell with my current setup.

chulee

Member

08:33AM, Dec 02, 2006

David, I tried and it seems to be working. But not 100% though. It doesn’t track every orders I’ve had which is weird. Like I mentioned earlier, I’ve had 5 orders since I put the code in but it shows only 2 on the GA.

---

http://www.shopmodi.com
design gifts + modish home accessories

DavidC

Member

02:46PM, Dec 02, 2006

lee – thank for the feedback. Is there anything in common between the orders you do see in GA, versus the ones you don’t see, or is it completely random? Not sure what it could be at this point.

chulee

Member

08:49AM, Dec 03, 2006

David, I think it’s completely random. So odd!! How is yours? Does this happen to you? or anybody that use this code?

---

http://www.shopmodi.com
design gifts + modish home accessories

danW

Shopify Advisor

08:58PM, Dec 03, 2006

all mine have so far been accounted for by google. No problems here.

Leo in Victoria

Member

11:44PM, Dec 07, 2006

I just want to say thank you to all of you people out there who are working so hard to resolve this. I keep checking back, completely confident that you will all eventually work out all of the bugs and kinks. We all benefit from your diligence.

Thank You.

---

Leo in Victoria
www.barbsart.ca—Beautiful art for a wonderful planet

hypersigil

Member

12:03AM, Dec 09, 2006

I implemented this last week, and thought it wasn’t working. Turns out that transactions are being recorded for the purpose of calculation in the Cost-Per-Conversion stats, but on the analytics page, I see no transactions being recorded under the e-commerce summary.

Zippy

Member

05:20AM, Dec 11, 2006

i did as David suggested and GA recorded the 1 sale that happened (that i had tried out myself:)). GA also recorded the 77 unique visitors that the site attracted today. Love it! GA has a wealth of information and i can’t wait to start mining it!

Ana Rita

Member

02:59PM, Dec 15, 2006

I have finally got some sale records showing on GA. Thank you! Here are two links that show how to get some more information out of GA with Adwords:

How to Assess Search & Content Network Advertising using Google Analytics

How to Get Detailed PPC Keyword Data from Google Analytics

Has anyone got Goal Tracking to work? I have this configuration for sales tracking but nothing is coming in:

Goal URL:

https://checkout.shopify.com/orders/7470/*

Defined Funnel Navigation:
http://www.myshop.com/cart
http://www.myshop.com/checkout
https://checkout.shopify.com/carts/7470/*
https://checkout.shopify.com/orders/*/pay

This is my G2. My G1 is “buying intention”, where Goal Url is defined as: http://www.myshop.com/cart . About 5% of my visitors is adding things to the cart and it would be very useful to know where are they abandoning the cart.
Thank you

Leo in Victoria

Member

05:38PM, Dec 17, 2006

Tobi, with all the information that has emerged, I am not sure that your original instructions are still valid. Are there any changes or should I go ahead and do what it says in the original post? – Thanks.

---

Leo in Victoria
www.barbsart.ca—Beautiful art for a wonderful planet

tobi

jaded Pixel

06:07PM, Dec 17, 2006

True. Maybe someone should post a guide on the wiki like the one for google base export. I’d replace this post with this then.

---

Tobias Lütke
Shopify – Founder, CEO

danW

Shopify Advisor

09:27PM, Dec 17, 2006

Leo,

In the mean time, David’s post is the one that got my tracking working.

The one that starts with,

“I have just seen the first e-commerce tracking transaction show up in my GA reports. It does work. Here’s what I have:

On the checkout & payment preferences page, in the additional content & scripts section:”

Leo in Victoria

Member

07:25AM, Dec 18, 2006

Thank you Tobi and Dan

---

Leo in Victoria
www.barbsart.ca—Beautiful art for a wonderful planet

Kati

Member

08:03AM, Dec 18, 2006

David’s code didn’t work for me, and i am troubleshooting it with GA customer support. They just told me what might be causing the problem, but I will wait to see if mine works now before I post the correction here. (It’s weird that it works for David, but doesn’t for me…)

I’ll let you all know later today when my GA account is refreshed and shows (or doesn’t) the new test sale.

---

Folkology – Authentic folk craft and culture from Hungary
http://www.folkology.com

danW

Shopify Advisor

10:06AM, Dec 18, 2006

Here is what I have. Replace the XXXX with your code from analytics. In the Profile Information of your domain, make sure you have e-commerce website selected

theme.liquid code


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-XXXXXX-XX";
urchinTracker();
</script>

cart.liquid code


<form action="/cart" method="post" id="cart" onSubmit="javascript:__utmLinkPost(this);">

checkout preferences code


<div style="display:none;">
<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"></script>

<form name="utmform">
<textarea id="utmtrans">
UTM:T|{{order_name}}||{{total_price|money_without_currency}}|{{tax_price|money_without_currency}}|{{shipping_price|money_without_currency}}|{{shipping_address.city}}|{{shipping_address.province}}|{{shipping_address.country}}
{% for line in line_items %}
UTM:I|{{order_name}}|{{line.sku}}|{{line.title}}||{{line.price|money_without_currency}}|{{line.quantity}}
{% endfor %}
</textarea>
</form>

<script type="text/javascript">
_uacct="UA-XXXXXX-XX"; _udn="none"; _ulink=1; urchinTracker(); __utmSetTrans(); 
</script>
</div>

We are also using Paypal Payments Pro. Not sure if this makes a difference in reference to the way the checkout flows but this code has been working for us.

Ana Rita

Member

07:06PM, Dec 18, 2006

No other orders were accounted by GA since my last comment. Two in total. With different payment methods. Is anyone else having such an irregular behaviour?

chulee

Member

02:48AM, Dec 19, 2006

My GA tracked all order made by me for the test purposes and just a few more out of 20 orders I’ve had. I have no idea what could’ve been wrong.

---

http://www.shopmodi.com
design gifts + modish home accessories

Claudia

Member

04:51AM, Dec 19, 2006

Sorry if this is a dumb question: where in the cart.liquid do you put the code? And my cart.liquid already has a div id for cart. Do I need to change that? (The validator says I can’t use the same id twice).

I put these codes in earlier but nothing showed up in Analytics. Correction: it says my revenue is $0.01!

Thanks DanW, David, you are the bee’s knee’s.

danW

Shopify Advisor

06:17AM, Dec 19, 2006

Hi Claudia,

The only thing that needs to be added to cart.liquid is this.

onSubmit="javascript:__utmLinkPost(this);"

Add this to the end of the form tag.

Kati

Member

09:03AM, Dec 19, 2006

My head is about to explode from all this tracking mess. I have exchanged about 10 emails with GA support, and it still doesn’t track sales.

So far all the things they have told me to change are things that work for all of you other shopify guys who use the code from this thread.

First they told me that the tracking code on the thank you page is not implemented correctly because the code is split in half. So I changed it to this (put the general tracking code at the beginning as one code block):

<div style="display:none;">
<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct="UA-XXXXXX-X"; _udn="folkology.com"; _ulink=1; urchinTracker(); 
</script>

<form name="utmform">
<textarea id="utmtrans">
UTM:T|{{order_name}}||{{total_price|money_without_currency}}|{{tax_price|money_without_currency}}|{{shipping_price|money_without_currency}}|{{shipping_address.city}}|{{shipping_address.province}}|{{shipping_address.country}}
{% for line in line_items %}
UTM:I|{{order_name}}|{{line.sku}}|{{line.title}}||{{line.price|money_without_currency}}|{{line.quantity}}
{% endfor %}
</textarea>
</form>

<script type="text/javascript">
__utmSetTrans(); 
</script>
</div> 

Still not tracking sales. (Sidenote: They said that splitting the code in half “is not supported implementation. It is possible that this implementation is causing discrepancy in recording the transactions. Please ensure that the tracking code is installed as a single block. The __utmSetTrans() function can be called later using another set of <script> tags.”)

So then I emailed them again, and now they say:

I reviewed
your website and found that when a user clicks on the ‘PROCEED TO
CHECKOUT!’ image and also on the payment option images, the links are not
tagged with the __utmLinker() function. This function keeps track of the
user’s cookies. I suggest you tag all the links from your main site to the
shopping cart site using the __utmLinker() function. Also, please install
the tracking code on the website that asks the user the mode of payment
(shop.folkology.com/checkout).

To know how you can tag your URLs using the __utmLinker() function, please
visit the Help Center article
http://google.com/support/analytics/bin/answer.py?answer=26915.

Since I don’t think any of you who are successfully tracking sales have this utmLinker stuff implemented, I don’t want to do it either. (Besides, the utlmlinpost thing in the cart form should serve the same purpose as utmLinker, right?)

Yesterday for a brief moment I thought that maybe the cart form could be the culprit. The submit button is an image, and maybe it is not triggering the onSubmit Javascript event? Or maybe it doesn’t trigger it in all browsers? But then I looked at DanW’s site, and his checkout button also is an image and his sales track. So this is not likely to be the main culprit. (Although if there is such a bug in some browsers – which I do not know, it’s just a hypothetical scenario that popped up in my head while trying to find what might cause tracking problems – that would explain why some of the sales do not track for you guys.)

So now I ran out of ideas on what to do. Anyone have any ideas on what could be causing the problem? (And any of the Javascript wizards here have any comments on the onsubmit not being triggered thought?)

---

Folkology – Authentic folk craft and culture from Hungary
http://www.folkology.com

Kati

Member

09:09AM, Dec 19, 2006

PS. DanW, I noticed you have

onSubmit="javascript:__utmLinkPost(this);"
while the GA support docs and David’s code has
onSubmit="javascript:__utmLinkPost(this)"
(notice the presence and the lack of semicolon at the end of the code)
Does this have any importance?

---

Folkology – Authentic folk craft and culture from Hungary
http://www.folkology.com

Ana Rita

Member

03:12PM, Dec 19, 2006

Maybe its something to do with paypal (standard) integration. I made a test order with paypal before we opened the shop and I don’t remember being brought back to the thank you page. The jaded pixel team wrote somewhere in this forum that there is nothing to configurate in paypal for it to work. True, its working. But maybe auto-return is glitchy.

Ana Rita

Member

02:02PM, Dec 20, 2006

One hint about goal tracking in GA: I just noticed I have ”/orders” on “Content Drilldown” reports.

Kati

Member

04:21PM, Feb 06, 2007

I am still stuck in the same place with the GA tracking (that is, it’s still not working)... :(

I don’t think it’s paypal that’s causing the problem, because my test orders using the bank transfer method (manual payment) do not track either.
If anyone has any ideas re: my post above dated Dec 19 (09:03AM), i would really aprecite your help.

---

Folkology – Authentic folk craft and culture from Hungary
http://www.folkology.com

Beechy

Member

12:57PM, May 04, 2007

I have ecommerce tracking working perfectly using the post by danW Dec 18 (10:06AM)

I am using Website payments Pro US

But have also got it to work on another shopify site that I am testing at the moment using the Bogus Gateway.

I now want to setup the Goal tracking. Have there been any further developments with regards to Davids post
Nov 27 (04:11AM).

At the moment I put in the following as my funnel:

1. MY STORES HOMEPAGE
www.shop.mystorename.com

2. SHOPPING CART PAGE
www.shop.mystorename.com/cart

3. ADDRESS INPUT PAGE
https://checkout.shopify.com/carts/18###/#########8dca344cf7825f5cd######

4. PAYMENT PAGE
https://checkout.shopify.com/orders/1####/######b7e5a861a016a866f41a######/pay

5. THANKYOU PAGE AND MY GOAL PAGE IN GOOGLE https://checkout.shopify.com/orders/1####/######b7e5a861a016a866f41a######

Im pretty sure that 1 & 2 URLs will work fine

However im also pretty sure that URls 3,4,5 will not work as the numbers change depending on the product chosen.

Does anyone have any advice with regards to the possible static urls that I could use.

Thanks

Dominic E

Member

04:37PM, Jun 21, 2007

Thanks for all the great work everyone did to get Google Analytics working with our Shopify stores. I have successfully implemented the tracking on my first shopify store and all the data is coming in.

Question:
I have initially setup Google Analytics to track mystore.myshopify.com but now we have changed the Domain DNS records in Shopify so our store is redirected to shop.mystore.com. Do I need to setup a new profile in Google Analytics to track shop.mystore.com? Or will it still work with the profile I have set for mystore.myshopify.com?

gh3go

Member

05:34PM, Dec 03, 2007

Mhhh ‘m trying to setup a funnel on intention of buy using mysite.com/cart/ as goal but it seems not to work…

any advice?

jonathanbriggs

Member

10:00AM, Jul 13, 2008

Google tracking of PayPal integration – is the above still valid since google updated its tracking code?

I have searched the wiki and found no article on goal tracking. Has anyone done this in the last 6 months.

Let me know whether you used DanW’s code.

Jonathan

---

www.marketquarter.com
http://marketquarter.blogspot.com

The Market Quarter
French Food Delivered from London’s Borough Market

You must login to post a comment!

Don't have an account yet? Sign up for one.