Announcement

Collapse
No announcement yet.

Where do I put Google Analytics code???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Zachery
    replied
    In the future it is best to start your own thread instead of bumping others moderately old threads.

    You'd want to place the code in the headinclude template.

    Leave a comment:


  • Drakie
    replied
    The new analytics code should be placed within the header, how do I do that? (across all themes)

    Leave a comment:


  • Coppers Lot
    replied
    BUMP

    ENF, Thanks for this mini tut.
    I have vb 4.1.2 and following your instructions have placed my GA code as you describe.

    If you have any more coding instructions let me know.

    Leave a comment:


  • Fergal
    replied
    Originally posted by sparky View Post
    Can I add the standard and advanced code since we use both?
    Google say,
    We recommend that you do not use both new and old tracking code snippets together on any given page. Doing so might generate inaccurate report data. You can, however, migrate select pages of your site to the new tracking code while the older tracking code remains on others.

    Leave a comment:


  • sparky
    replied
    Can I add the standard and advanced code since we use both?

    Leave a comment:


  • ENF
    replied
    Originally posted by vincent-a View Post
    Is there a VB plugin or an option within Admin to add google analytics (or any other analytics) please?
    Adding code to templates puts us at risk to forget whenever a new template is used.
    Thanks,

    - Vincent
    I don't use this, but this is what you asked for: (Google Analytics)

    http://www.vbulletin.org/forum/showthread.php?t=229347

    If Google changes their code, you'll need to update this mod yourself or wait for the author to do so. Thus, I prefer manually adding in the code.

    Good Luck.

    Leave a comment:


  • vincent-a
    replied
    Is there a VB plugin or an option within Admin to add google analytics (or any other analytics) please?
    Adding code to templates puts us at risk to forget whenever a new template is used.
    Thanks,

    - Vincent

    Leave a comment:


  • Wannakno
    replied
    Thanks again ENF, i'll let you know if there is any problem!

    Leave a comment:


  • ENF
    replied
    Originally posted by Wannakno View Post
    ok so i should put the GA code @ the VERY bottom after the last </div> ??

    i just need the report to kick in already

    Thanks for all the help
    Yes, just make sure you use the format I gave you in post #2, the <vb:literal> tags are the key to making it work in VB4. Insert the code, save and watch your stats start to roll in. I believe it will take a few hours for actual stats to appear in Google Analytics, but it should confirm that it's receiving data after you insert the code into your forum and view a few pages.

    Leave a comment:


  • Wannakno
    replied
    ok so i should put the GA code @ the VERY bottom after the last </div> ??

    i just need the report to kick in already

    Thanks for all the help

    Leave a comment:


  • ENF
    replied
    NO <*/body> <*/html> @ end
    That's correct, it shows up on the GENERATED page of your forum. In your template, just insert the code right after </div> at the very bottom as I noted in my first post above. Then, when you look at your forum pages through "View Source" you can see that it was inserted sucessfully. The </body> and </html> don't show in the template, only on the actual page viewed in your browser.

    Leave a comment:


  • Wannakno
    replied
    this is what my footer looks like without the code:


    Code:
    {vb:raw ad_location.ad_footer_start}
    {vb:raw ad_location.global_above_footer}
    <div id="footer" class="floatcontainer footer">
    
        <form action="{vb:raw vboptions.forumhome}.php" method="get" id="footer_select" class="footer_select">
    
                
            <vb:if condition="$show['quickchooser']">
                <select name="styleid" onchange="switch_id(this, 'style')">
                    <optgroup label="{vb:rawphrase quick_style_chooser}">
                        {vb:raw quickchooserbits}
                    </optgroup>
                </select>    
            </vb:if>
            
            <vb:if condition="$show['languagechooser']">
                <select name="langid" onchange="switch_id(this, 'lang')">
                    <optgroup label="{vb:rawphrase quick_language_chooser}">
                        {vb:raw languagechooserbits}
                    </optgroup>
                </select>
            </vb:if>
        </form>
    
        <ul id="footer_links" class="footer_links">
            <vb:if condition="$show['contactus']"><li><a href="{vb:raw vboptions.contactuslink}" rel="nofollow" accesskey="9">{vb:rawphrase contact_us}</a></li></vb:if>
            <vb:if condition="$vboptions['hometitle']"><li><a href="{vb:raw vboptions.homeurl}">{vb:raw vboptions.hometitle}</a></li></vb:if>
            <vb:if condition="$show['admincplink']"><li><a href="{vb:raw admincpdir}/index.php{vb:raw session.sessionurl_q}">{vb:rawphrase admin}</a></li></vb:if>
            <vb:if condition="$show['modcplink']"><li><a href="{vb:raw modcpdir}/index.php{vb:raw session.sessionurl_q}">{vb:rawphrase mod}</a></li></vb:if>
            <vb:if condition="$vboptions['archiveenabled']"><li><a href="archive/index.php">{vb:rawphrase archive}</a></li></vb:if>
            {vb:raw template_hook.footer_links}
            <vb:if condition="$vboptions['privacyurl']"><li><a href="{vb:raw vboptions.privacyurl}">{vb:rawphrase privacy_statement}</a></li></vb:if>
            <vb:if condition="$vboptions['tosurl']"><li><a href="{vb:raw vboptions.tosurl}">{vb:rawphrase terms_of_service}</a></li></vb:if>
            <li><a href="{vb:raw relpath}#top" onclick="document.location.hash='top'; return false;">{vb:rawphrase top}</a></li>
        </ul>
        
        
        <vb:if condition="$show['dst_correction']">
        <!-- auto DST correction code -->
            <form action="profile.php?do=dst" method="post" name="dstform">
                <input type="hidden" name="s" value="{vb:raw session.sessionhash}" />
                <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
                <input type="hidden" name="do" value="dst" />
            </form>
            <script type="text/javascript">
            <!--
                var tzOffset = {vb:raw bbuserinfo.timezoneoffset} + {vb:raw bbuserinfo.dstonoff};
                var utcOffset = new Date().getTimezoneOffset() / 60;
                if (Math.abs(tzOffset + utcOffset) == 1)
                {    // Dst offset is 1 so its changed
                    document.forms.dstform.submit();
                }
            //-->
            </script>
            <!-- / auto DST correction code -->
        </vb:if>
        
        <script type="text/javascript">
        <!--
            // Main vBulletin Javascript Initialization
            vBulletin_init();
        //-->
        </script>
            {vb:raw template_hook.footer_javascript}
    </div>
    </div><!-- closing div for body_wrapper -->
    
    <div class="below_body">
    
    <div id="footer_copyright" class="shade footer_copyright">
        <!-- Do not remove this copyright notice -->
        {vb:rawphrase powered_by_vbulletin}
        <!-- Do not remove this copyright notice -->    
    </div>
    <div id="footer_morecopyright" class="shade footer_morecopyright">
        <!-- Do not remove cronimage or your scheduled tasks will cease to function -->
        {vb:raw cronimage}
        <!-- Do not remove cronimage or your scheduled tasks will cease to function -->
        {vb:raw vboptions.copyrighttext}
    </div>
    
    {vb:raw ad_location.ad_footer_end} 
    </div>
    NO <*/body> <*/html> @ end

    Leave a comment:


  • ENF
    replied
    Originally posted by Wannakno View Post
    where exactly in the footer please??
    When you look at the bottom of your footer temaplate, there should be a closing </div>. We put the code above just after that and then it looks like this on the generated page:

    Code:
    </div>
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "[URL]https://ssl[/URL]." : "[URL]http://www[/URL].");
    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-X");
    pageTracker._trackPageview();
    } catch(err) {}</script>
     
    </body>
    </html>
    This has worked fine in VB3 and Vb4 so far.

    Leave a comment:


  • Wannakno
    replied
    where exactly in the footer please??

    Leave a comment:


  • ENF
    replied
    We use the footer, but you must use the <vb:literal> tags.

    Example:

    Code:
    <vb:literal>
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "[URL]https://ssl[/URL]." : "[URL]http://www[/URL].");
    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-XXXXXXXX-X");
    pageTracker._trackPageview();
    } catch(err) {}</script>
    </vb:literal>

    Leave a comment:

Related Topics

Collapse

  • Danloona
    like widghet
    by Danloona
    Hello , i have a problem with a little widget .

    I want to put this code Like widget to be next Google , But this code is going down

    code:
    PHP Code:
    <!-- Put this script tag to 
    ...
    Fri 18 Dec '15, 6:42am
Working...
X