WordPress.org

Ready to get started?Download WordPress

Forums

adding google analytics code (2 posts)

  1. 9reddoors
    Member
    Posted 3 years ago #

    Hoping someone knowledgeable can help me out here:). I wanted to add google analytics tracking code to my Twenty Ten Template as I decided not to use a GA plugin (apparently this gives a third party access to reports data).

    I found instructions to add GA code into the themes function .php via.
    The website url where I found these instructions and the code they said to paste in is:

    http://www.wpbeginner.com/beginners-guide/how-to-install-google-analytics-in-wordpress/

    Their instructions read as follows-

    How to Install Google Analytics in WordPress
    There are 3 ways to install Google analytics in WordPress. Direct paste, functions.php, and plugins....

    anyway, I copied the .php method below:

    Functions.php Method

    Add the following code in your theme’s functions.php file and don’t forget to paste your Google Analytics code from Step 6 here.

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

    I struck a problem or two after pasting in the codes.
    I removed the code and updated the themes function.php thinking all would return to how it was originally. But no...

    Then I got a syntax error like this:

    Parse error: syntax error, unexpected '<' in /home/myusername/public_html/wp-content/themes/twentyten/functions.php on line 510

    I do not understand why and I cannot get access to the admin area of my website anymore. I have contacted the hosting company to see if they can tell me what has happened.

    Grateful for any help asap.

    Cheers,
    :/

  2. dbonomo
    Member
    Posted 2 years ago #

    It looks like you still have some errant code laying around in the functions.php file. Did you try restoring it from a backup?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.