adding google analytics code
-
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:https://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,
:/
- The topic ‘adding google analytics code’ is closed to new replies.