Announcement

Collapse
No announcement yet.

Adding Google Analytics Question

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

  • Adding Google Analytics Question

    A previous admin had tried to setup Analytics in the past, and the code was still in there. I created my own Analytics account and want to install it myself. I have a couple of questions.

    I have read people say to remove the <script> tags. Can you be more specific?

    Here's the code Google gives me:

    <!-- Global Site Tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-1"></script>

    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments)};
    gtag('js', new Date());

    gtag('config', 'UA-XXXXXXXXX-1');
    </script>

    Do I remove everything in bold? The line with the link to googletagmanager confuses me. How do I remove the <script> tags from that? How should it look if I'm not removing it completely?

    Question 2: The old code that was in there, as well as an example posted on this site with a similar question earlier this year, is completely different than the one Google is giving me. It looks like this:

    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-XXXXXXXXX-1', 'auto');
    ga('send', 'pageview');

    Which one is right? I don't see that old code anywhere. Did Google change it up?


  • #2
    I am in the exact same situation. The current google analytics code is different from the old code.
    https://www.mylumolife.com/

    Comment


    • #3


      I would think you could create a new template if you can't find a solution.

      1) Create a new template called footer_google_analytics.

      2) Paste your Google code into it. Save the template.

      3) Go to Products and Hooks in the Admin CP. Click "Add New Hook".

      4) Select "footer_copyright" as the Hook Location.

      5) Give it the title, Google Analytics

      6) For the template name enter footer_google_analytics

      7) Save the hook.

      Other wise, wouldn't putting the code in the footer template before </body> tag work? Or put the code in header include.
      Last edited by William Thomas Jr; Sun 22nd Oct '17, 4:47pm.

      Comment


      • Wayne Luke
        Wayne Luke commented
        Editing a comment
        vBulletin Cloud doesn't have access to Template Hooks or to edit Templates directly.

    • #4
      Thanks for your reply William. I will try your suggestions later and report back if I have any problems.
      https://www.mylumolife.com/

      Comment


      • #5
        We're working to update the software to handle the new format. Currently, you have to add it like this:

        Code:
        </script>
        <!-- Global Site Tag (gtag.js) - Google Analytics -->
        <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-1"></script>
        <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments)};
        gtag('js', new Date());
        
        gtag('config', 'UA-XXXXXXXXX-1');
        </script>
        <script>
        I am sorry for the confusion.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud customization and demonstration site.
        vBulletin 5 Documentation - Updated every Friday. Report issues here.
        vBulletin 5 API - Full / Mobile
        I am not currently available for vB Messenger Chats.

        Comment


        • braintrainnerd
          braintrainnerd commented
          Editing a comment
          Should that be <script> at the top and </script> at the bottom?

          Also, in ACP > settings > options > Expand settings group, in the list there are 3 settings related to Analytics - "Google Analytics Account ID", "Enable Google Analytics" and "Google Analytics Javascript". I entered your suggested code into the "Enable Google Analytics" settings, but it doesn't appear to be working - analytics doesn't show anybody visiting my forum, even though I am browsing it. Should I be editing any of the other 2 settings on the list?

        • Wayne Luke
          Wayne Luke commented
          Editing a comment
          In the AdminCP go to Settings -> Options -> Search Engine Tools.

          Set "Enable Google Analytics" to Yes.
          Copy your code in the Google Analytics Javascript box. The closing (</script>) and opening script (<script>) tags that I posted are necessary in that order with the new code at this time.

          Those are the only two options that need to be changed for Analytics.

          Looking at the site, you switched the closing and opening tags that I added in my example above. This breaks the code. They need to be switched like I have them.

      • #6
        Thanks a lot Wayne, it's working now.
        https://www.mylumolife.com/

        Comment


        • #7
          Hello
          Wayne Luke Set "Enable Google Analytics" to Yes.
          Copy your code in the Google Analytics Javascript box. The closing (</script>) and opening script (<script>) tags that I posted are necessary in that order with the new code at this time.
          I have vBulletin 5.3.3
          Do we still add those extra java script tags in there like that?

          Thank You for Your Time!!!!!
          RUBE
          Thank You for Your Time!
          RUBE

          Comment


          • #8
            Originally posted by RUBE View Post
            Hello


            I have vBulletin 5.3.3
            Do we still add those extra java script tags in there like that?

            Thank You for Your Time!!!!!
            RUBE
            Yes. They will not be needed in 5.4.0. However, you code shouldn't break if they are left in.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud customization and demonstration site.
            vBulletin 5 Documentation - Updated every Friday. Report issues here.
            vBulletin 5 API - Full / Mobile
            I am not currently available for vB Messenger Chats.

            Comment


            • #9
              Originally posted by Wayne Luke View Post

              Yes. They will not be needed in 5.4.0. However, you code shouldn't break if they are left in.
              Thank You Sir for your quick response and...

              Thank You for Your Time!!!!!
              RUBE

              Thank You for Your Time!
              RUBE

              Comment


              • #10
                So using the script code at top as an example, what is the correct format for vB 5.4.0?

                Comment


                • #11
                  Originally posted by Solid Signal View Post
                  So using the script code at top as an example, what is the correct format for vB 5.4.0?

                  Code:
                  <!-- Global Site Tag (gtag.js) - Google Analytics -->
                  <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-1"></script>
                  <script>
                  window.dataLayer = window.dataLayer || [];
                  function gtag(){dataLayer.push(arguments)};
                  gtag('js', new Date());
                  
                  gtag('config', 'UA-XXXXXXXXX-1');
                  </script>
                  Translations provided by Google.

                  Wayne Luke
                  The Rabid Badger - a vBulletin Cloud customization and demonstration site.
                  vBulletin 5 Documentation - Updated every Friday. Report issues here.
                  vBulletin 5 API - Full / Mobile
                  I am not currently available for vB Messenger Chats.

                  Comment

                  Related Topics

                  Collapse

                  Working...
                  X