Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4229
Latest: Ghost
New This Month: 3
New This Week: 0
New Today: 0
Stats
Total Posts: 43064
Total Topics: 7492
Most Online Today: 124
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 1
Guests: 48
Total: 49

Author Topic: how to insert Google analytics code  (Read 17498 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: 16349
    • 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: 16349
    • 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
7518 Views
Last post December 17, 2010, 11:51:27 am
by Michel68
15 Replies
12935 Views
Last post February 11, 2012, 12:08:07 pm
by SMFHacks
2 Replies
3304 Views
Last post July 16, 2012, 01:37:10 pm
by XHIBIT
2 Replies
2244 Views
Last post February 12, 2013, 06:49:50 pm
by tekgik
2 Replies
3571 Views
Last post February 23, 2014, 05:45:21 am
by Sweetwater

+- Recent Topics

Follow / Follower Mod? by Nicole
Today at 07:21:11 pm

[Mod]Discord Web Hooks by SMFHacks
Today at 03:57:28 pm

SMF 2.1.4 Search by Anmer
Today at 01:55:15 pm

Looking for a good video player by SMFHacks
September 21, 2023, 06:06:46 am

Error in thise mode by Ghost
September 15, 2023, 08:42:24 am

Gallery Selection List Order by mickjav
September 07, 2023, 12:46:31 pm

[Mod]Tidy Child Boards 2.0 by Norwinjose
September 02, 2023, 11:42:54 am

PrettyUrls SEO Pro: Unable to submit sitemap to google search conmsole by SMFHacks
August 31, 2023, 10:55:22 am

PrettyURL - SEO4SMF Rewrites? by SMFHacks
August 28, 2023, 06:35:33 pm

Web versus Mobile by SMFHacks
August 28, 2023, 03:12:57 pm

Powered by EzPortal