No announcement yet.

Inserting Google Analytics Code into Archive

  • Filter
  • Time
  • Show
Clear All
new posts

  • [Forum] Inserting Google Analytics Code into Archive

    (vBulletin 4.1.0 Patch Level 2)

    I've inserted Google Analytics on my forum as described in this thread. However, that does not add the Analytics code to the archive.

    How can I add the Google Analytics code to my forum archive?

    Fergal Crawley
    Business Advice Forum

    Forum Promotion

  • #2
    There was a thread around here somewhere, but I cannot seem to find it. But, off hand, you can do this:

    1) Create a file called analytic.php in your Arhcive directory where index.php resides. (./archive/index.php)
    2) Inside this new file, add this code: (add your UA number)

     <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "' type='text/javascript'%3E%3C/script%3E"));
      <script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-xxxxxx-x");
    </script> <?php 
    // Close Google Analytics code 
    3) save this file

    4) edit the index.php file in the Archive folder and add this line to the bottom of the index.php, but before the ?> at the very end.
    include 'analytic.php';
    This will add the tracking to each page clicked in the archive.

    I'm not sure if there is a better way to do this... I am open to opinions. But, this works until a better solution presents itself.

    Downside to this method is upgrading vb with new files.
    To be updated...


    • #3
      Problem with this is that the new analytics code goes before the </head> tag. Any idea how to add it in the archives with the new code?

      The header part is included in the archive index with some kind of print command and that screws it up.
      Talk About Marriage - The marriage and relationship forums.


      • #4
        This is what I see for the header in that file:

            <meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . vB_Template_Runtime::fetchStyleVar('charset') . "\" />
            <link rel=\"stylesheet\" type=\"text/css\" href=\"" . $vbulletin->options['bburl'] . "/archive/archive.css\" />
        Don't see any print command there or reference to it?
        Vote for:

        - *Admin Settable Paid Subscription Reminder Timeframe*
        *PM - Add ability to reply to originator only*
        - Add Admin ability to auto-subscribe users to specific channel(s)
        - "Quick Route" Interface...


        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.