Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 11845
Latest: SamoanOnion
New This Month: 6
New This Week: 0
New Today: 0
Stats
Total Posts: 42472
Total Topics: 7406
Most Online Today: 127
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 98
Total: 98

Author Topic: how to insert Google analytics code  (Read 17160 times)

0 Members and 1 Guest are viewing this topic.

Offline ubintook

  • Member
  • *
  • Posts: 5
    • View Profile
how to insert Google analytics code
« on: October 08, 2009, 05:48:56 pm »
There has been a thread going at simple machine regarding insertion of Google analytics code
There does to seem to be any real agreement on the correct manner to insert the code.
i have tried most of the "common" ways but all end up in a parsing error.
I am using smf1.1.10 with a theme called outline form dziner studio
any suggestions?


Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16109
    • View Profile
Re: how to insert Google analytics code
« Reply #1 on: October 09, 2009, 09:34:03 am »
Just insert into index.template.php of the theme using an echo statement you  need to escape any of the 's to avoid parse errors.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline ApplianceJunk

  • Sr. Member
  • ****
  • Posts: 432
    • View Profile
    • ApplianceJunk.com
Re: how to insert Google analytics code
« Reply #2 on: October 09, 2009, 04:31:33 pm »
I just followed the instruction were I got the Google analytics code.  ;)

Quote
Copy the following code block into every webpage you want to track immediately before the </body> tag.

I placed the code in the index.template.php, immediately before the </body> tag. :)

Offline ubintook

  • Member
  • *
  • Posts: 5
    • View Profile
Re: how to insert Google analytics code
« Reply #3 on: October 09, 2009, 04:47:25 pm »
I just followed the instruction were I got the Google analytics code.  ;)

Quote
Copy the following code block into every webpage you want to track immediately before the </body> tag.

I placed the code in the index.template.php, immediately before the </body> tag. :)

I did that and get a parsing error...thats why i thought there was an issue.

Offline ubintook

  • Member
  • *
  • Posts: 5
    • View Profile
Re: how to insert Google analytics code
« Reply #4 on: October 09, 2009, 04:54:45 pm »
Just insert into index.template.php of the theme using an echo statement you  need to escape any of the 's to avoid parse errors.
Example?

here is my code(minus tracking number)
Code: [Select]
<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-8");
pageTracker._trackPageview();
} catch(err) {}</script>

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16109
    • View Profile
Re: how to insert Google analytics code
« Reply #5 on: October 12, 2009, 01:48:37 pm »
Below
Code: [Select]
echo '
<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-8");
pageTracker._trackPageview();
} catch(err) {}</script>
';
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline ubintook

  • Member
  • *
  • Posts: 5
    • View Profile
Re: how to insert Google analytics code
« Reply #6 on: October 12, 2009, 04:00:24 pm »
not sure what is happening, but i still get a parsing error, i have attached my index.template.php. ( i munged the Google code)
Now, i have been editing the file from within the theme that i am using, should i be editing a different one?
thoughts on why this is happening?


Offline ubintook

  • Member
  • *
  • Posts: 5
    • View Profile
Re: how to insert Google analytics code
« Reply #7 on: October 16, 2009, 02:30:37 pm »
a mod to insert analytics code has been created at the SMF forums:
http://www.simplemachines.org/community/index.php?topic=341997.0

Offline flodo

  • Member
  • *
  • Posts: 1
    • View Profile
Re: how to insert Google analytics code
« Reply #8 on: January 11, 2010, 05:09:13 am »
thanks :) :) :)

Offline insy111

  • Member
  • *
  • Posts: 2
    • View Profile
    • Wall Stickers India
Re: how to insert Google analytics code
« Reply #9 on: March 22, 2012, 06:24:50 am »
a mod to insert analytics code has been created at the SMF forums:
http://www.simplemachines.org/community/index.php?topic=341997.0

That's extremely helpful, thanks!

 

Related Topics

  Subject / Started by Replies Last post
6 Replies
7296 Views
Last post December 17, 2010, 11:51:27 am
by Michel68
15 Replies
12587 Views
Last post February 11, 2012, 12:08:07 pm
by SMFHacks
2 Replies
3199 Views
Last post July 16, 2012, 01:37:10 pm
by XHIBIT
2 Replies
2183 Views
Last post February 12, 2013, 06:49:50 pm
by tekgik
2 Replies
3499 Views
Last post February 23, 2014, 05:45:21 am
by Sweetwater

+- Recent Topics

"Custom title" badge by SMFHacks
September 24, 2022, 07:09:22 pm

Category Selection by Anmer
September 18, 2022, 02:40:06 am

Setting a single free download. by Zaphod
September 12, 2022, 10:18:45 pm

Error message "Data too long for column 'ipaddress' at row 1" by SMFHacks
September 12, 2022, 08:49:02 am

SMF to SMF bridge via WP by SMFHacks
September 11, 2022, 09:44:30 am

Video player included by SMFHacks
September 06, 2022, 10:26:27 pm

Upload hangs / doesn't complete by SMFHacks
August 28, 2022, 08:36:21 am

[Feature Request] Admin Sales Alert by Shades
August 25, 2022, 06:41:00 pm

Portal Block by SMFHacks
August 23, 2022, 12:42:22 pm

Question about undoing a rating by SMFHacks
August 22, 2022, 04:31:50 pm

Powered by EzPortal