Google Analytics input on vbulletin 5 forum

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Maltair
    Senior Member
    • Feb 2009
    • 575
    • 5.7.5

    Google Analytics input on vbulletin 5 forum

    Been a while, where do I input this again? I don't see it in the vb5 Admin Control Panel.
    Last edited by Maltair; Sun 13 Aug '17, 3:55pm.
  • glennrocksvb
    Former vBulletin Developer
    • Mar 2011
    • 4011
    • 5.7.X

    #2
    In AdminCP > Settings > Options. Then look for Google Analytics. Do not include the <script></script> tags when you paste the Analytics code.

    Flag Icon Postbit Insert GIPHY Impersonate User BETTER INITIALS AVATAR Better Name Card Quote Selected Text Bookmark Posts Post Footer Translate Stop Links in Posts +MORE!

    Comment

    • Maltair
      Senior Member
      • Feb 2009
      • 575
      • 5.7.5

      #3
      Found it, it is AdminCP > Settings > Options > Search Engine Tools

      They got rid of a separate "Google Analytics" pulldown menu at some point.

      Comment


      • glennrocksvb
        glennrocksvb commented
        Editing a comment
        Oh ok. Didn't know that.
    • alfreema
      Senior Member
      • Sep 2017
      • 144
      • 5.3.x

      #4
      This is broken now, because VB5 wraps the code with script tags, but Google is providing this:

      PHP Code:
      <!-- Global site tag (gtag.js) - Google Analytics -->
      <
      script async src="https://www.googletagmanager.com/gtag/js?id=***"></script>

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

        
      gtag('config''***');
      </
      script
      So to make it work you have to add a close script tag at the top, and an open script tag at the bottom.

      PHP Code:
      </script>
      [... 
      paste Google code in exactly as they ask you to ...]
      <
      script
      It would be ideal if vb5 didn't try to wrap the Google code at all and just let us paste exactly what Google asks us to -- which would only require removing those automatically generated script tags.

      Comment

      • glennrocksvb
        Former vBulletin Developer
        • Mar 2011
        • 4011
        • 5.7.X

        #5
        I totally agree with you alfreema. But if they did that, all vB5 sites with GA will break and site owners must manually update their code. I think the acceptable solution now is to have a logic to check if script tags exist. If yes then don't include them, otherwise include them. Not an ideal solution but it avoids breakage for all existing sites.

        Flag Icon Postbit Insert GIPHY Impersonate User BETTER INITIALS AVATAR Better Name Card Quote Selected Text Bookmark Posts Post Footer Translate Stop Links in Posts +MORE!

        Comment

        • alfreema
          Senior Member
          • Sep 2017
          • 144
          • 5.3.x

          #6
          Originally posted by Glenn Vergara
          I totally agree with you alfreema. But if they did that, all vB5 sites with GA will break and site owners must manually update their code. I think the acceptable solution now is to have a logic to check if script tags exist. If yes then don't include them, otherwise include them. Not an ideal solution but it avoids breakage for all existing sites.
          Yes, or automatically prepend and append the script tags into the user's existing GA code during the update (because 100% of existing users are expecting it to be there) and then stop automatically including them in code from that point on?

          Comment


          • glennrocksvb
            glennrocksvb commented
            Editing a comment
            That would work too. You have to file an improvement request in JIRA for it to be considered and implemented.
        • Maltair
          Senior Member
          • Feb 2009
          • 575
          • 5.7.5

          #7
          This is what I pasted in on my vb5

          (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','https://www.google-analytics.com/analytics.js','ga');

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

          This is correct and no need to change.

          Comment

          • Wayne Luke
            vBulletin Technical Support Lead
            • Aug 2000
            • 73979

            #8
            Originally posted by alfreema
            This is broken now, because VB5 wraps the code with script tags, but Google is providing this:

            PHP Code:
            <!-- Global site tag (gtag.js) - Google Analytics -->
            <
            script async src="https://www.googletagmanager.com/gtag/js?id=***"></script>

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

            gtag('config''***');
            </
            script
            So to make it work you have to add a close script tag at the top, and an open script tag at the bottom.

            PHP Code:
            </script>
            [... 
            paste Google code in exactly as they ask you to ...]
            <
            script
            It would be ideal if vb5 didn't try to wrap the Google code at all and just let us paste exactly what Google asks us to -- which would only require removing those automatically generated script tags.
            I am pretty sure this would be considered to be a potential exploit. I don't know why the script tags are added automatically but it would have to do with vBulletin Cloud. That is why Google Analytics was added at all.

            On the download version, you can avoid all this simply by creating a template that hooks into the footer.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API

            Comment

            • glennrocksvb
              Former vBulletin Developer
              • Mar 2011
              • 4011
              • 5.7.X

              #9
              Originally posted by Wayne Luke

              I am pretty sure this would be considered to be a potential exploit. I don't know why the script tags are added automatically but it would have to do with vBulletin Cloud.
              But there are other places where you can add <script> tags such as in HTML modules, Ad modules, Announcements, Notices and Phrases. I don't understand why it would single out GA settings.

              Flag Icon Postbit Insert GIPHY Impersonate User BETTER INITIALS AVATAR Better Name Card Quote Selected Text Bookmark Posts Post Footer Translate Stop Links in Posts +MORE!

              Comment

              • alfreema
                Senior Member
                • Sep 2017
                • 144
                • 5.3.x

                #10
                Originally posted by Wayne Luke

                I am pretty sure this would be considered to be a potential exploit. I don't know why the script tags are added automatically but it would have to do with vBulletin Cloud. That is why Google Analytics was added at all.

                On the download version, you can avoid all this simply by creating a template that hooks into the footer.
                The Google Analytics code itself has script tags in it, therefore the same injection that could be used sans automatic wrapping of script tags can be used with automatic wrapping of script tags (just locate them inside of Google's code instead of prepending it). It's simply use at your own risk functionality. So now the decision for VB is just a matter of convenience for your end users and minimizing support problems. It's inconvenient for the end user to autowrap the block with script tags, and will cause support issues.

                Don't get me wrong, I'm not complaining (because I know how to work around the problem). But I am not going to open a JIRA because I don't have time to learn how. I just wanted to point out it's "broken" based on how Google is currently dumping their javascript -- there's no way to remove script tags per the instructions, so I am just trying to help others out that have the same problem.
                Last edited by alfreema; Tue 17 Oct '17, 9:40am.

                Comment


                • Wayne Luke
                  Wayne Luke commented
                  Editing a comment
                  But I am not going to open a JIRA because I don't have time to learn how.
                  If you can post in this forum, you know everything you need to know about creating a bug report in the issue tracker.
              • mrwhitee
                Member
                • Nov 2012
                • 44
                • 5.3.x

                #11
                Originally posted by alfreema
                This is broken now, because VB5 wraps the code with script tags, but Google is providing this:

                PHP Code:
                <!-- Global site tag (gtag.js) - Google Analytics -->
                <
                script async src="https://www.googletagmanager.com/gtag/js?id=***"></script>

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

                gtag('config''***');
                </
                script
                So to make it work you have to add a close script tag at the top, and an open script tag at the bottom.

                PHP Code:
                </script>
                [... 
                paste Google code in exactly as they ask you to ...]
                <
                script
                It would be ideal if vb5 didn't try to wrap the Google code at all and just let us paste exactly what Google asks us to -- which would only require removing those automatically generated script tags.
                Thanks man! I didnt know what the hell was going on. VB page says one thing and goole another. I got it working with your solution.

                Comment

                • Wayne Luke
                  vBulletin Technical Support Lead
                  • Aug 2000
                  • 73979

                  #12
                  The wrappers will not be needed in 5.4.0. http://tracker.vbulletin.com/browse/VBV-17799
                  Translations provided by Google.

                  Wayne Luke
                  The Rabid Badger - a vBulletin Cloud demonstration site.
                  vBulletin 5 API

                  Comment

                  • mrwhitee
                    Member
                    • Nov 2012
                    • 44
                    • 5.3.x

                    #13
                    cool, good to know.

                    Comment

                    Related Topics

                    Collapse

                    Working...