Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1417224

    Leanna
    Participant

    Hi amazing X theme techs!
    I am trying to add Google Analytics code to Functions.php in Child theme, and messed up the site! I got it back by re-uploading the original Functions file but seek your assistance in how to put in the code.
    My web host says to use this code:

    
    <?php
    
    add_action('wp_footer', 'add_googleanalytics');
    
    function add_googleanalytics() { ?>
    
    // Paste your Google Analytics code from Step 6 here
    
    <?php } ?>

    The Google Analytics website says that this is our Analytics code:

    
    <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','https://www.google-analytics.com/analytics.js','ga');
    
      ga('create', 'UA-22707452-1', 'auto');
      ga('send', 'pageview');
    
    </script>
    

    Please let me know how to insert this into Functions.php without breaking the site.
    thanks

    #1417231

    Leanna
    Participant
    This reply has been marked as private.
    #1417239

    Leanna
    Participant

    Never mind u answered my question in another post, thanks!

    #1417269

    Friech
    Moderator

    Glad we could help, Cheers!

    #1417271

    Leanna
    Participant

    HELP!!! Goog Analytics was working fine for awhile then suddenly the site went down again with this error:
    Parse error: syntax error, unexpected ‘<‘ in /home/tellas5/public_html/wp-content/themes/x-child/functions.php on line 44

    So I ripped the Gog Analytics code out of Functions.php again, now the site is STILL NOT WORKING UNLESS I manuallytype in “https://www.tellasia.org” If I just put “tellasia.org” in the url field, it gives the same error.

    So even without the Analytics code, something seems to be messed up. Please check… and plz fix or tell us how to fix.

    Here’s the code we put in Functions.php in Child theme (which is not currently there as it seems to have put the whole site down after working for a short time):

    
    // Add Google Analytics
    // =============================================================================
    function third_party_tracking_code() { ?>
    
    <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','https://www.google-analytics.com/analytics.js','ga');
    
      ga('create', 'UA-22707452-1', 'auto');
      ga('send', 'pageview');
    
    </script>
    
    <?php }
    
    add_action( 'wp_footer', 'third_party_tracking_code' );
    
    // =============================================================================
    #1417357

    Darshana
    Moderator

    Hi there,

    It seems that you have changed your WP login credentials. We need FTP credentials to check your issue.

    Thanks!

    #1417369

    Leanna
    Participant
    This reply has been marked as private.
    #1417476

    Paul R
    Moderator

    Hi Leanna,

    Please provide us ftp access in private reply so we can add the code properly.

    Thanks

    #1417487

    Leanna
    Participant
    This reply has been marked as private.
    #1417503

    Darshana
    Moderator

    Hi there,

    Yes, please remove that code and use our Google Analytics extension. We have a complete integration guide here (https://community.theme.co/kb/extension-google-analytics/).

    Thanks!

    #1417555

    Leanna
    Participant

    It works, thank you!
    Now all we need to solve is why, when I type “tellasia.org” into Chrome without adding www, I’m still getting “Parse error: syntax error, unexpected ‘<‘ in /home/tellas5/public_html/wp-content/themes/x-child/functions.php on line 44”

    this is very concerning because nobody manually types www nowdays…

    I’ve cleared all cache in browser and website but still occuring on all my computers.

    #1417562

    Darshana
    Moderator

    Hi there,

    I have checked your site on Chrome & Firefox, but I could not experience such issue. If you can check with another computer in a different location and see if you get the same issue.

    Thanks!

    #1418773

    Leanna
    Participant

    ok thanks. The problem continues in India on all our computers, but nobody in the US can replicate the error. Odd.

    #1418871

    Lely
    Moderator

    Hi Leanna,

    I can’t duplicate the issue. When I type tellasia.org it redirect to https://www.tellasia.org/ and loads properly.

    #1419361

    Leanna
    Participant

    ok