Tracking code shows on front end?

This topic contains 8 replies, has 3 voices, and was last updated by  Paolo 10 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #13794

    [email protected]
    Free User
    Post count: 11

    Hi all

    Spot of bother here – I noticed that the tracking code shows up on the front end! I’m using the Modern child theme. I noticed this, entered a bogus code to a) verify that the code I was seeing on the front end was coming from the Geodirectory>general area of the control panel and b) make the screen shot.

    I’ve deleted my code for now, in case this is a security risk. Screenshot is attached. Halp! 🙂

    #13797

    Simone
    Expired Member
    Post count: 3515

    Hello, silly question: did you past the full code? (maybe some tag is missing)

    #13804

    [email protected]
    Free User
    Post count: 11

    Simone

    Attached is a screenshot of where I’m entering the code: Geodirectory menu on WP>General>Google Analytics. Yellow highlight is where the UA code should go. I’ve used other plugins on more vanilla WP sites, and this format is always UA-XXXXXXX-XX.

    For example, I’ve frequently used this plugin:
    https://wordpress.org/plugins/googleanalytics/

    and the instructions read, in part:
    Activate the plugin through the ‘Plugins’ menu in WordPress
    Add the web property ID from Google Analytics (UA-0000000-0) to the settings (Admin > Settings > Google Analytics)

    So I don’t think this field is (or should be) set up for the user to enter php coding or the like – all you should need is the Google code… if it’s invalid obviously it should either trap the error or just not work, but if the code is now displayed on the front end I think you’ve got a bug.

    #13817

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    sorry to say this, but you should never assume that a plugin should work like any another plugin or use references like that, because behind any plugin there is a different developer.

    In there you need to paste the whole tracking code that google provides

    Example:

    
    
    <script>
      (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-52472672-1', 'auto');
      ga('send', 'pageview');
    
    </script>

    Otherwise we would have wrote, paste the google analytics tracking ID (not code)

    Thx

    #13831

    [email protected]
    Free User
    Post count: 11

    Paolo

    I was just trying to walk you through what I was thinking. A number of plugins just insert the UA code as a variable, since the rest of the code snippet is pretty much going to be the same. OK, that worked, or at least, doesn’t show on the front end. Thanks.

    I would suggest that if you want the user to insert 8-10 lines of code a text area of similar size would help them get the picture.

    #13832

    [email protected]
    Free User
    Post count: 11

    also, some listings display this…

    #13854

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    that is just a php warning that shouldn’t be printed and should only be logged in your php error log.

    Try adding this to your theme functions.php file after the opening

    error_reporting(E_ERROR);

    Let us know,

    Thanks

    #13856

    [email protected]
    Free User
    Post count: 11

    OK – added with a comment right below the opening comment like so:

    
    
    <?php 
    /*#############################################
    HERE YOU CAN ADD YOUR OWN FUNCTIONS OR REPLACE FUNCTONS IN THE PARENT THEME
    #############################################*/
    
    /*suppress error reporting on the front end*/
    error_reporting(E_ERROR);

    Seems to work – the error was only showing on brand new listings (I’m guessing that there is a calculation being made and when visits = 0 it’s trying to divide by it). I now get

    Google Analytics (Last 30 days)
    No stats yet

    Which is good – thanks.

    #13857

    Paolo
    Site Admin
    Post count: 31206

    excellent, I’ll mark this as solved.

    Thanks!

Viewing 9 posts - 1 through 9 (of 9 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount