Priya jain
Priya jain

Reputation: 703

How do I add Google Analytic to my WordPress site without using plugin?

I have a script like

 <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("xx-xxxxxxx-x");
    pageTracker._trackPageview();
    } catch(err) {} 
    </script>

So how do i use it works in my site? Please help me to get the solution..

Upvotes: 0

Views: 66

Answers (2)

Adam Falchetta
Adam Falchetta

Reputation: 85

Go to Appearance>Widgets and add "Custom HTML" to any of your sidebar widgets and past the code in there.

Make sure to including the:

<script>...</script>

Upvotes: 0

Siyah
Siyah

Reputation: 2897

<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("xx-xxxxxxx-x");
    pageTracker._trackPageview();
    } catch(err) {} 
    </script>

Add this snippet in the header.php or head.php in your files, just before the end of the </head> tag.

Upvotes: 1

Related Questions