Forums / General Questions / Google Analytic s Question

Google Analytic s Question

Results 1 to 9 of 9
09 Jan 2013, 18:21
#1
portfj62 avatar

portfj62

New Zenner

Join Date:
Jun 2012
Posts:
30
Plugin Contributions:
0

Google Analytic s Question

It says Im supposed to paste this script on the home page and others for tracking and results.
Can I paste this is the html through ez pages? If not where? Do I need to pull up the php files and insert
it there? Im a bit confused on this, should not be difficult I know.

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-37469995-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
09 Jan 2013, 18:46
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Google Analytic s Question

You'll get far better analytics results if you use the Plugin from the Plugins library.

But if you really want to just paste that stuff into your site and get only the very basic data, paste it into a new file which you upload to:
/includes/templates/NAME_OF_YOUR_ACTIVE_TEMPLATE/jscript/jscript_mygoogleanalytics.php
09 Jan 2013, 18:51
#3
portfj62 avatar

portfj62

New Zenner

Join Date:
Jun 2012
Posts:
30
Plugin Contributions:
0

Re: Google Analytic s Question

Where is the plugins library? Is that process straight forward?
09 Jan 2013, 18:58
#4
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Posts:
10,324
Plugin Contributions:
0

Re: Google Analytic s Question

How "straight forward" is "straight forward" ?

... depends on your understanding of web-mastership.

If you are a competent webmaster, then the process is straight-forward.

If you are not a competent webmaster, the process can be frustratingly complex.

This plugin is quite detailed, so you need to be diligent when installing it.

There is a link above called PLUGINS...

Look for SIMPLE GOOGLE ANALYTICS for ZC 1.5

or click this link: http://www.zen-cart.com/downloads.php?do=file&id=272
09 Jan 2013, 20:11
#5
cheapstairparts avatar

cheapstairparts

Zen Follower

Join Date:
Oct 2007
Posts:
149
Plugin Contributions:
0

Re: Google Analytic s Question

find your template footer page -- includes/templates/your-template/common/tpl_footer.php

you can paste it there somewhere . That is how mine is setup.
09 Jan 2013, 21:22
#6
portfj62 avatar

portfj62

New Zenner

Join Date:
Jun 2012
Posts:
30
Plugin Contributions:
0

Re: Google Analytic s Question

Thank you.

Paste in the main body section?
09 Jan 2013, 23:26
#7
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Posts:
10,324
Plugin Contributions:
0

Re: Google Analytic s Question

PortFJ62:

Thank you.

Paste in the main body section?


Better, actually, to paste it into tpl_main_page.php, because that file has the closing </body> tag.

Here are the last few lines of code of the CORE FILE.

[PHP]<!--bof- banner #6 display -->
<?php
if (SHOW_BANNERS_GROUP_SET6 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET6)) {
if ($banner->RecordCount() > 0) {
?>
<div id="bannerSix" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
}
}
?>
<!--eof- banner #6 display -->
</body>[/PHP]

The Google code goes just above the </body> tag.

<!--eof- banner #6 display -->
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-37469995-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</body>

This is the "clunky" way to do things. It is BETTER (if you can) to use the plugin and the reason for this is that you can set various tracking parameters via the admin panel.

For example, later on you may want to build in some custom tracking code, or assimilate AdWords Tracking with Analytics. The plugin allows you to administer these sorts of things more easily than you would by hard-coding the google scripts.

But for now, if your analytics needs are simple, then do as I indicate above.

BEAR IN MIND that tpl_main_page is a CORE FILE. You will need to create an edited OVER-RIDE and place this edited copy into your custom template's COMMON folder.

EG:

CORE FILE: /includes/templates/template_default/common/tpl_main_page.php
OVERRIDE FILE: /includes/templates/YOUR_TEMPLATE_FOLDER/common/tpl_main_page.php
10 Jan 2013, 06:08
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Google Analytic s Question

schoolboy:

BEAR IN MIND that tpl_main_page is a CORE FILE.

And so is tpl_footer.php as suggested by someone else.

That's why I suggested putting it in a completely separate self-contained jscript_.....php file so that nothing else needs messing with. The only downside is that it will load at the top of the page instead of the bottom. Not much of an issue, but some purists will say it makes their skin crawl to do that.


So, as you can see, there are many ways to do it. Pick whichever you like.
10 Jan 2013, 10:22
#9
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Posts:
10,324
Plugin Contributions:
0

Re: Google Analytic s Question

DrByte:

That's why I suggested putting it in a completely separate self-contained jscript_.....php file so that nothing else needs messing with. The only downside is that it will load at the top of the page instead of the bottom. Not much of an issue, but some purists will say it makes their skin crawl to do that.


With Analytics using asynchronous loading (text/javascript'; ga.async = true;)it should not matter whether it's in the header, or at the end of the </body> section.