Zen Cart Logo
Forums / All Other Contributions/Addons / Google Analytics Integration

Google Analytics Integration

Views: 225,772

Results 61 to 80 of 660
19 Oct 2006, 20:11
#61
jrb1512 avatar

jrb1512

Zen Follower

Join Date:
Sep 2006
Location:
Cheshire, UK
Posts:
100
Plugin Contributions:
0

Google Analytics Integration

i have found that the google code is above the body tags it appears to be in the header, i can't locate the footer file with the code in, can anyone help?

02 Nov 2006, 11:35
#62
magicpants avatar

magicpants

Zen Follower

Join Date:
Aug 2005
Posts:
314
Plugin Contributions:
0

Re: Google Analytics Integration

I had a serious javascript / ajax problem when using this Google Analytics mod and with GZIP Compression turned on in the admin. I turned GZip Compression off and it seems to work fine.

Just a heads up, if you're having trouble. And, what was the final verdict about putting the google code above the body tags? Should we move it to where Google recommends it to be?

02 Nov 2006, 13:16
#63
mafiasam avatar

mafiasam

Zen Follower

Join Date:
Jan 2006
Location:
Portland, Oregon
Posts:
256
Plugin Contributions:
0

Re: Google Analytics Integration

cuda:

Well I have been looking to use this module but concerned that if google analytics goes down my site will not load because this mod includes everything at the top. Google actually tells you to include the code at the bottom of the page just before the </body> tag to avoid this issue. So I have come up with a hack to include the code at the bottom. Here it is:

First we need to move files around a bit so they will not load at the top but at the bottom.

  1. Create a new folder in includes/templates/yourtemplate named 'bottom_jscript'

  2. Now move 'jscript_google_analytics.php' to the new folder

  3. Create a new folder in includes/modules/pages/checkout_success named 'google_analytics'

  4. Move 'jscript_google_analytics.php' and 'on_load_google_analytics.js' to this new folder.

Ok now we have our files in the new folders lets move to the hack.

  1. We will add the code below to includes/templates/yourtemplate/common/tpl_main_page.php at the very bottom just before the body tag as instructed by google - and yes I would jump off a bridge if google said too.... :blink:

/** Google Analytics Main Code include

  • load all site-wide bottom jscript_*.php files from includes/templates/YOURTEMPLATE/bottom_jscript/, alphabetically
    */
    $directory_array = $template->get_template_part($template->get_template_dir('.php',DIR_WS_TEMPLATE, $current_page_base,'bottom_jscript'), '/^jscript_/', '.php');
    while(list ($key, $value) = each($directory_array)) {

/**

  • include content from all site-wide bottom jscript_*.php files from includes/templates/YOURTEMPLATE/jscript, alphabetically.
  • These .PHP files can be manipulated by PHP when they're called, and are copied in-full to the browser page
    */
    require($template->get_template_dir('.php',DIR_WS_TEMPLATE, $current_page_base,'bottom_jscript') . '/' . $value); echo "\n";
    }

//check to see if current page is checkout_success and include google analytics for order if it is
if($page_directory == 'includes/modules/pages/checkout_success')
{

/**

  • load all google_analytics-specific jscript_*.js files from includes/modules/pages/PAGENAME/google_analytics, alphabetically
    /
    $directory_array = $template->get_template_part($page_directory . 'google_analytics', '/^jscript_/', '.js');
    while(list ($key, $value) = each($directory_array)) {
    echo '<script type="text/javascript" src="' . $page_directory . 'google_analytics' . '/' . $value . '"></script>' . "\n";
    }
    /
    *
  • include content from all google_analytics-specific jscript_*.php files from includes/modules/pages/PAGENAME/google_analytics, alphabetically.
    /
    $directory_array = $template->get_template_part($page_directory . '/google_analytics', '/^jscript_/');
    while(list ($key, $value) = each($directory_array)) {
    /
    *
  • include content from all google_analytics-specific jscript_*.php files from includes/modules/pages/PAGENAME, alphabetically.
  • These .PHP files can be manipulated by PHP when they're called, and are copied in-full to the browser page
    */
    require($page_directory . '/google_analytics' . '/' . $value); echo "\n";
    }
    }
> 
> That is it now the code will be included on each page and the cart contents will be included at checkout success, had to use a simple check to avoid running code for every page as it is not needed. 
> 
> I will be testing this but works so far let me know if you have any thoughts.

Hi cuda,
I was just wondering if the google analytics solution you came up with to move the code to the footer  as seen above is still working?

thanks in advance
hope to hear from you soon
02 Nov 2006, 14:38
#64
cuda avatar

cuda

Zen Follower

Join Date:
Jul 2006
Posts:
119
Plugin Contributions:
0

Re: Google Analytics Integration

The problem I am having is getting the e-commerce analytics to work. The tracking all works great in this hack but no e-commere sales tracking does not.

I also changed the code in includes/modules/pages/checkout_success/google_analytics/jscript_google_analytics.php

to echo just a hidden form and not a JS function (don't understand why this was used in the first place).

to do this change this at the bottom:

echo '<script type="text/javascript">
function zen_utmSetTrans() {
  var divHTML = "";
  divHTML += "<form style=\"display:none;\" name=\"utmform\">";
  divHTML += "  <textarea id=\"utmtrans\">";
  divHTML += "' . addslashes($transaction) . '";
  divHTML += "' . addslashes(trim($items)) . '";
  divHTML += "  </textarea>";
  divHTML += "</form>";
  var divUTM = document.createElement("div");
  divUTM.id = "utmform";
  divUTM.style.display = "none";
  divUTM.innerHTML = divHTML;
  document.body.appendChild(divUTM);
  __utmSetTrans();
}
</script>';

to this:

echo '<script language="text/javascript">
__utmSetTrans(); </script>'  .
'<form style="display:none;" name="utmform">
<textarea id="utmtrans">' 
. addslashes($transaction) . ' ' 
. addslashes(trim($items))
. '</textarea>
</form>';

now what is echoed on the checkout_success page is something like this:

<script type="text/javascript">
_uacct = "UA-XXXXXX-1";
urchinTracker();
</script>
<script language="text/javascript">
__utmSetTrans(); </script><form style="display:none;" name="utmform">
<textarea id="utmtrans">UTM:T|82||28.46|1.56|7.95|City|State|United States UTM:I|82|64|Product name|Product Category|18.95|1</textarea>
</form>

This seems to follow what the google analytics help page suggests is needed here:
http://www.google.com/support/analytics/bin/answer.py?answer=27203&topic=7282

The info we are getting is great but being able to track sales would be even better. Maybe it has something to do with all the cart info is on one line I will have to test that. Any help on this would be great.

Are people who are using the default module able to track sales?

02 Nov 2006, 15:56
#65
cuda avatar

cuda

Zen Follower

Join Date:
Jul 2006
Posts:
119
Plugin Contributions:
0

Re: Google Analytics Integration

Doing some more reading it apears you need to also set up a goal in google analytics see these resources:

info from another cart system that you must setup a goal:
http://forums.volusion.com/archive/index.php/t-810.html

setting up a goal:
http://www.google.com/support/analytics/bin/answer.py?answer=26926&topic=7282
http://www.google.com/support/analytics/bin/answer.py?answer=26910

hope these help some will report back if setting up a goal solved the e-commerce tracking problem...stay tuned

02 Nov 2006, 20:36
#66
mafiasam avatar

mafiasam

Zen Follower

Join Date:
Jan 2006
Location:
Portland, Oregon
Posts:
256
Plugin Contributions:
0

Re: Google Analytics Integration

cuda:

Doing some more reading it apears you need to also set up a goal in google analytics see these resources:

info from another cart system that you must setup a goal:
http://forums.volusion.com/archive/index.php/t-810.html

setting up a goal:
http://www.google.com/support/analytics/bin/answer.py?answer=26926&topic=7282
http://www.google.com/support/analytics/bin/answer.py?answer=26910

hope these help some will report back if setting up a goal solved the e-commerce tracking problem...stay tuned

Yeah I wasn't ready to install it until I was sure it was working properly. I also am reticent to install the latest patch because there has been some issues regarding some contributions and I just haven't had time to go chasing solutions to problems I can avoid for now.

I really need to set up my store for testing on my computer. That would help tons.

Let me know if it works. My goal are working now but I do not have the hack that you posted.

mafiasam

02 Nov 2006, 20:52
#67
cuda avatar

cuda

Zen Follower

Join Date:
Jul 2006
Posts:
119
Plugin Contributions:
0

Re: Google Analytics Integration

once I get it working perfectly, at least for the shop I am workin on, I will try and package it all up for everyone as a mod. With better directions.

02 Nov 2006, 20:54
#68
mafiasam avatar

mafiasam

Zen Follower

Join Date:
Jan 2006
Location:
Portland, Oregon
Posts:
256
Plugin Contributions:
0

Re: Google Analytics Integration

cuda:

once I get it working perfectly, at least for the shop I am workin on, I will try and package it all up for everyone as a mod. With better directions.

thanks cuda

06 Nov 2006, 21:28
#69
cuda avatar

cuda

Zen Follower

Join Date:
Jul 2006
Posts:
119
Plugin Contributions:
0

Re: Google Analytics Integration

I am still having troubles getting analytics to track my sales it tracks my funnel goal to conversion but nothing for product info.

If someone has google analytics tracking your site and getting sales data could you please post the code from your checkout page so I can get this resolved. So an example from a site that is getting product info from there checkout_success page would be greatly appreciated!!! :smile:

Thanks all

07 Nov 2006, 00:52
#70
mafiasam avatar

mafiasam

Zen Follower

Join Date:
Jan 2006
Location:
Portland, Oregon
Posts:
256
Plugin Contributions:
0

Re: Google Analytics Integration

cuda:

I am still having troubles getting analytics to track my sales it tracks my funnel goal to conversion but nothing for product info.

If someone has google analytics tracking your site and getting sales data could you please post the code from your checkout page so I can get this resolved. So an example from a site that is getting product info from there checkout_success page would be greatly appreciated!!! :smile:

Thanks all

i'm not really getting that info either unless you look at certain reports. what reports are you trying to retrieve the product info from. the only product info I can find is in the "reverse goal path" report under "content optimization"/"goals & funnel process". you kind of have to do some deduction I guess and compare your zencart orders to the "defined funnel navigation" and other reports.

if anyone can back me up here or prove me wrong please let me know because all that is holding cuda back from confirming his automated fix for the google analytics code placement is a little testing/proof that his is working.

07 Nov 2006, 10:32
#71
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: Google Analytics Integration

I can not understand your problems. My variant successfully works on several shops.

07 Nov 2006, 15:57
#72
mafiasam avatar

mafiasam

Zen Follower

Join Date:
Jan 2006
Location:
Portland, Oregon
Posts:
256
Plugin Contributions:
0

Re: Google Analytics Integration

a_berezin:

I can not understand your problems. My variant successfully works on several shops.

does it place the code in the footer as suggested by google?

07 Nov 2006, 21:20
#73
cuda avatar

cuda

Zen Follower

Join Date:
Jul 2006
Posts:
119
Plugin Contributions:
0

Re: Google Analytics Integration

Tracking sales/Revenue is the only problem I am having. I get no e-commerce analytics at all everything says $0.00 even with many sales going through.

On the chechout_success page what does your code output look like? I am having troubles with either the order of javascript calls or a slight formating problem.

Are you using the suggested onload JS call in the body tag or the script call like this:

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

Just an output of your checkout success page would be great assuming you are getting revenue data in your analytics menu's.

Thanks

08 Nov 2006, 08:17
#74
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: Google Analytics Integration

You can download this mod and see anything.

08 Nov 2006, 14:24
#75
gmoyle avatar

gmoyle

Zen Follower

Join Date:
Jan 2004
Location:
Reno, NV
Posts:
98
Plugin Contributions:
1

Re: Google Analytics Integration

Whew, I just thought I didn't know what I was doing. I installed this mod a couple weeks ago and have not had any luck with any ecommerce tracking info either. :(

I hadn't seen any postings to that effect, and just hadn't had the time to post one myself.

Glad I am not alone.

08 Nov 2006, 14:34
#76
cuda avatar

cuda

Zen Follower

Join Date:
Jul 2006
Posts:
119
Plugin Contributions:
0

Re: Google Analytics Integration

a_berezin:

You can download this mod and see anything.

Are you getting e-commerce tracking a_berezin with dollar values?

08 Nov 2006, 14:44
#77
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: Google Analytics Integration

I work only with one currency and I don't need to convert from my currency to USD.

08 Nov 2006, 14:59
#78
cuda avatar

cuda

Zen Follower

Join Date:
Jul 2006
Posts:
119
Plugin Contributions:
0

Re: Google Analytics Integration

No the question is in google analytics are you actually getting e-commerce revenue data and product info from the products that have sold as reported by your chechout success page?

It does not matter what currency you are using and no conversion is being done here...

08 Nov 2006, 19:40
#79
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: Google Analytics Integration

You ask me about dollar values. I have answered, that the currency has no importance for me.

I have all e-commerce report in Google Analitics. Including sales reports. And products info with prices and taxes.

08 Nov 2006, 20:07
#80
jrb1512 avatar

jrb1512

Zen Follower

Join Date:
Sep 2006
Location:
Cheshire, UK
Posts:
100
Plugin Contributions:
0

Re: Google Analytics Integration

i cant move the script to the body tag even though i used the mod in question :( can someone help ive even contacted google they were useless