Support Forums

Adding Google Analytics

This is a discussion on Adding Google Analytics within the Technical Support forums, part of the Technical Support Forums category; Can someone please tell me what files and where to add Google Analytics code Many thanks....


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

This topic is resolved.

If you have a similar issue that this thread does not address, open a new related support topic.

 
Thread Tools Display Modes
Old 11-19-2008, 06:28 AM   #1
Member
 
Join Date: Apr 2006
Posts: 24
Rep Power: 23
gabs is on a distinguished road
Default Adding Google Analytics

Can someone please tell me what files and where to add Google Analytics code

Many thanks.
gabs is offline  
Old 11-19-2008, 07:00 AM   #2
Genius At Work
 
bowers01's Avatar
 
Join Date: May 2008
Location: Geelong, Victoria, Australia
Posts: 1,089
Rep Power: 35
bowers01 is on a distinguished road
Default

Open layout.tpl, just before the </body> place the code there inside
{literal}
google code
{/literal}

Cheers
__________________
Nick Bowers
68c v4.1.10 Developer Custom Template
bowers01 is offline  
Old 11-19-2008, 07:28 AM   #3
Member
 
Join Date: Apr 2006
Posts: 24
Rep Power: 23
gabs is on a distinguished road
Default

Legend!

Thanks a million!
gabs is offline  
Old 11-19-2008, 07:36 AM   #4
Genius At Work
 
bowers01's Avatar
 
Join Date: May 2008
Location: Geelong, Victoria, Australia
Posts: 1,089
Rep Power: 35
bowers01 is on a distinguished road
Default

No worries any time.
Nick
__________________
Nick Bowers
68c v4.1.10 Developer Custom Template
bowers01 is offline  
Old 01-26-2009, 11:23 PM   #5
Member
 
Join Date: Jan 2009
Posts: 41
Rep Power: 12
petey is on a distinguished road
Default stumped

Ok so now I have Google Analytics basic code on my layout.tpl, but how do I use the "Goal" tracking - where there needs to be some extra code to record e.g. an event like "user has confirmed their email address" so I can see where new members are coming from?

According to Google here, an extra line to call pageTracker._trackPageview() tracking code below needs to be added, since 68 doesn't have a specific unique url that is shown to GA for this event.

Code:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-xxxxx-yy");
pageTracker._trackPageview("/memberconfirmed.html");
} catch(err) {}</script>
The "/memberconfirmed.html" doesn't need to exist as a page, it's just a way to tell Google Analytics that this "url" was triggered and record the goal.

The problem is that although I know where this event happens in the code (in login.php), if I stick this script in there then it comes out too early before the layout.tpl generates the page.

I tried sticking the script into the "thanks for validating now you may login" string but this didn't work either.

Any suggestions on how to have this code above show only somewhere in the <body> area for this unique event?

I think this knowledge would help all 68 customers who use Google Analytics, as it would give us better information on where members who register are coming from.
__________________
(Running v4.0.9 Developer, Boat template + custom colours/gfx + SEO Plus by templatecodes.com)
petey is offline  
Old 01-27-2009, 08:19 AM   #6
curmudgeon
 
Join Date: Mar 2006
Posts: 5,415
Rep Power: 138
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by petey
Any suggestions on how to have this code above show only somewhere in the <body> area for this unique event?

I think this knowledge would help all 68 customers who use Google Analytics, as it would give us better information on where members who register are coming from.
You can easily use smarty logic (if/else etc etc) to check various smarty variables at the template level to see what page you are on and in turn display code.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 01-27-2009, 12:47 PM   #7
Member
 
Join Date: Jan 2009
Posts: 41
Rep Power: 12
petey is on a distinguished road
Default smarty

Oh ok.

I guess I'll have to learn how Smarty is used by 68 so I can create my own variable that's set at the time the email is validated and then checked later in the template.

Thanks.
__________________
(Running v4.0.9 Developer, Boat template + custom colours/gfx + SEO Plus by templatecodes.com)
petey is offline  
Old 01-27-2009, 01:02 PM   #8
curmudgeon
 
Join Date: Mar 2006
Posts: 5,415
Rep Power: 138
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by petey
Oh ok.

I guess I'll have to learn how Smarty is used by 68 so I can create my own variable that's set at the time the email is validated and then checked later in the template.

Thanks.
I think your missing the point OR I dont understand the question.

In your post, you asked how to have some bit of javascript be executed on a certain page only.

My reply was to evaluate an existing smarty variable to determine a page and then execute the JS.

in other words, since layout.tpl has the head of the page where javascript is generally stored stick your page specific code in layout.tpl with the rest of your google code.

The trick however is to surround it with a smarty {if} logical check to check for the page and if its the page you want to trigger the JS then, and only then will that JS be used.

Documents and posts all over this forum talk about placing {debug} at the top of the layout.tpl file to cause the smarty debug window to display which will show you all the smarty variables assigned from the underlying scripts. If you navigate to the page where you want the google JS to run look at the variables you have available.

You will notice that the $body variable changes on each page you visit and that the variable always holds the name of a template file.

Now, for example if I want the google JS to fire off ONLY when someone clicks the link "My Account" visit that page yourself and you will see the body variable is "user/userindex.tpl".

Now just use that in the smarty logic.....

Code:
{if $body=="user/userindex.tpl"}
{literal}
the google code here
{/literal}
{/if}
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 01-27-2009, 01:09 PM   #9
Member
 
Join Date: Jan 2009
Posts: 41
Rep Power: 12
petey is on a distinguished road
Default validation

I think we agree, but note that I want to trigger the code only once per new user - not every time they login. Otherwise I'd have incorrect conversion data.

So I need to look for a variable that's set when someone clicks that validation link in their email or else set one myself at that point in the login script.

I think I have enough to go on now. I'll report back once I've found the solution, if anyone else is interested in tracking their website conversions of new members.
__________________
(Running v4.0.9 Developer, Boat template + custom colours/gfx + SEO Plus by templatecodes.com)
petey is offline  
Old 01-27-2009, 01:18 PM   #10
curmudgeon
 
Join Date: Mar 2006
Posts: 5,415
Rep Power: 138
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

I didnt go through the trouble of registering a new user on one of my test sites BUT the logic still holds true. Set {debug} in layout.tpl. Register a new user and then click validate link in your e-mail and the debug console should pop up when the user hits your site and you can see what the body variable is. Then use that value in your smarty logic.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with adding google search suresh Technical Support 2 08-25-2008 09:59 AM
Google Analytics fabiorr Technical Support 2 07-03-2008 02:56 AM


All times are GMT -4. The time now is 08:29 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0