Facebook 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4292
Latest: MashaMl8417
New This Month: 4
New This Week: 3
New Today: 3
Stats
Total Posts: 43790
Total Topics: 7602
Most Online Today: 62
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 52
Total: 52

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

+- Recent Topics

[Mod]Cloudflare Turnstile for SMF by SMFHacks
May 08, 2025, 10:08:43 am

Disable "Notify me of Comments feature" by Kiwi
May 08, 2025, 02:04:16 am

Trying to access array offset on null by Michel68
May 05, 2025, 08:47:34 am

Default [Additional] Membergroups upon Registration by SMFHacks
April 30, 2025, 10:22:52 am

Sorted FTP Import Directory by SMFHacks
April 25, 2025, 05:11:22 am

Search results items per page? by SMFHacks
April 18, 2025, 04:12:23 pm

Suggestions and request by Senkusha
April 03, 2025, 02:30:43 pm

How does a member add a Classified Listing? by SMFHacks
March 28, 2025, 08:05:50 pm

Auto converting to webp or AVIF by [chrisB]
March 28, 2025, 01:46:00 pm

Thumbnail creation settings by SMFHacks
March 28, 2025, 12:42:51 pm

Powered by EzPortal