We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31227
    • 198 Posts
    so its not possible to have a snippet assigned to different templates? because I have 1 russian & 1 english template.
      Pure MODx sites
      Viriko.ru & Viriko.com - Multilingual and running on 1 MODx
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Plugins work by interrupting the normal processing of a document and inserting/modifying stuff. You would need to hack the plugin to have it check for which template the page being processed is using and insert whatever is wanted accordingly.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 31227
        • 198 Posts
        ehh unfortunately I am not big in coding:( well maybe it will be an idea for that may be implemented in the future version;)
          Pure MODx sites
          Viriko.ru & Viriko.com - Multilingual and running on 1 MODx
          • 30497
          • 245 Posts
          Quote from: ncrossland at Mar 14, 2008, 11:21 AM

          Quote from: bwente at Mar 06, 2008, 03:25 PM

          Why would you do this instead of a chunk in your templates?

          It has a few advantages
          * it respects the "log visits" setting on ModX pages in the manager - e.g. if you untick the box for one page, it will not get the tracking code on it
          * it also ignores visits when you are logged in to the manager (e.g. when QuickEditting)
          * it is easy to turn off for debugging (just a tick box in the Manager, instead of commenting out code)
          * it has some other interactive capabilities (like the ’alternative tracking URL’ functionality I recently added) which isn’t possible with chunks

          But, if chunks suit, there’s nothing wrong with them!

          After reading this thread I decided to try the plugin for GA instead of the chunk I have been using.

          The script on my html pages is now:
          <script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
          <script type="text/javascript">
          var pageTracker = _gat._getTracker("UA-0000000-1");
          pageTracker._initData();
          pageTracker._trackPageview();
          </script>
          
          


          it was this:
          <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">
          var pageTracker = _gat._getTracker("UA-0000000-1");
          pageTracker._initData();
          pageTracker._trackPageview();
          </script>


          Is that correct?

          Also, I see the script in this manner at the bottom of each HTML page, no matter if I am logged into manager or not. My plugin configuration is test mode "false" and version "new".

          I am using the latest plugin. I replaced part of my tracking code above with 0’s for the example.
            • 10896
            • 76 Posts
            Hey,

            I’m wondering if a flag can be added to the plugin so that in some cases <body> can be where the GA code is placed rather than </body>. In cases where I want to track out-bound links I need the google analytics code placed just after the opening <body> tag. I’ve modified the code appropriately but figured others may want this as well.

            http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55527

            Modified line 82 to get GA tracking appended to <body>:
            $modx->documentOutput = preg_replace("/(<body>)/i", "\\1\n".$script, $modx->documentOutput);
            
              • 25803 ☆ A M B ☆
              • 721 Posts
              I’ve installed 1.4 and it’s working perfectly on one site but doesn’t show up at all on two others (one of which is on the same server as the functioning one) despite all the settings being exactly the same (Tracking ID excepted of course). I see reference to having Test Mode set to 0 or 1 (not true or false.) I have all of them set to false.

              I simply don’t understand how it can work for one site and none of the others, using the exact same settings and same versions of MODx .9.6.1p2. Anyone else run into this problem and solved it?
                • 25663 MODX Staff
                • 12,272 Posts
                Clear the site cache then log out of the manager. By default GA doesn’t create the tracking links when you’re logged into the manager since those aren’t likely to be "real" hits to your site.
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 10896
                  • 76 Posts
                  Earlier I noted a possible feature addition using this code to put the GA code after the opening body tag

                  $modx->documentOutput = preg_replace("/(<body>)/i", "\\1\n".$script, $modx->documentOutput);
                  


                  However, I noted that searching for ’<body>’ isn’t always possible as body can have many attributes such as a class or id, etc. I’m thinking this may be a better regex but I’m not sure if it’s bullet-proof.

                  $modx->documentOutput = preg_replace("/(<body.*?>)/i", "\\1\n".$script, $modx->documentOutput);
                  


                  HTH
                    • 25803 ☆ A M B ☆
                    • 721 Posts
                    Quote from: rthrash at Jul 07, 2008, 08:33 AM

                    Clear the site cache then log out of the manager. By default GA doesn’t create the tracking links when you’re logged into the manager since those aren’t likely to be "real" hits to your site.

                    Thank you. I had done both but still it persists. I suspect it’s one of those problems one can spend hours on so I’ll just put the code in the template itself.
                      • 4198
                      • 4 Posts
                      The plugin code does not seem to result in an exact pattern-match to the Google Analytics supplied code (at least for me)

                      So.. on the Google Analytics "Settings" page, the "Status" is "Tracking Not Installed".
                      - I did check after clearing the cache
                      - it does appear to be reporting properly

                      Anyone else having the same issue? Or not?
                      Any reason to not pattern-match as Google Analytics expects? (perhaps this has some advantage)

                      Thanks!

                      Note: my next step is to more fully investigate:
                      How can I confirm I’ve entered the tracking code correctly on my pages?