Tagged: google analytics, header
-
AuthorPosts
-
November 9, 2020 at 1:43 pm #1259253
Hello, when I ad Google Analytics code in the custom Enfold field then the code is not placed in the header. Is there any way to force Enfold to place the GA code in the header?
Thanks :)
Alwin
November 9, 2020 at 7:30 pm #1259359Hey Alwin,
Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?
Best regards,
VictoriaNovember 12, 2020 at 3:20 pm #1260145Hello,
I’ve the same problem: I need to put the Google analytics code into the header.
Where/how can I do it.
Thanks<!– Global site tag (gtag.js) – Google Analytics –>
<script async src=”https://www.googletagmanager.com/gtag/js?id=G-xxxxxxxx”></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(‘js’, new Date());gtag(‘config’, ‘G-xxxxxxxxx’);
</script>November 13, 2020 at 2:45 am #1260254Hi,
Refer to Mike’s post here:
https://kriesi.at/support/topic/enfold-child-theme-add-google-analytics-code/#post-951578
Best regards,
Jordan ShannonNovember 18, 2020 at 3:25 pm #1261291Hello Jordan,
I’ve tried and nothing was successful. Google has a new Analytics tool since the 14.10.20.
Google recommends:
___________________________________________
Add gtag.js to your site
The global site tag (gtag.js) is a JavaScript tagging framework and API that allows you to send event data to Google Analytics, Google Ads, and Google Marketing Platform. This page describes how to use gtag.js to configure a site for Google Analytics. For general (i.e. non-product specific) gtag.js documentation, read the gtag.js developer guide.Install the global site tag
To install the global site tag, copy the following code and paste it immediately after the <head> tag on every page of your site. Replace GA_MEASUREMENT_ID with the ID of the Google Analytics property to which you want to send data. You need only one global snippet per page.<!– Global site tag (gtag.js) – Google Analytics –>
<script async src=”https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID”></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(‘js’, new Date());gtag(‘config’, ‘GA_MEASUREMENT_ID’);
</script>This snippet loads the gtag.js library, establishes GA_MEASUREMENT_ID as the default Google Analytics property ID, and sends a pageview hit to Google Analytics.
__________________________________________________
But in enfold child theme there is no header And putting the snippet into the field in in the recommended custom Enfold field it does not work.
Thanks for looking into thatNovember 18, 2020 at 3:42 pm #1261296Hey,
Please add following code to bottom of Functions.php file of your child theme in Appearance > Editor
//------------------------------- // Google Analytics code in head section //------------------------------- function av_ga_code_head(){ ?> // Your GA code here <?php } add_action('wp_head', 'av_ga_code_head');
Our devs are already informed about new GA code issue :)
Regards,
YigitNovember 18, 2020 at 4:11 pm #1261303Thanks Yigit,
at the bottom of the child functions.php I find these three last lines.</script>
<?php
}
?>Do I need to include the code at the very bottom, or before the <?php ?
Thanks for your help
November 18, 2020 at 4:19 pm #1261308Hey,
You would need to add your GA code to where it says “// Your GA code here”
//------------------------------- // Google Analytics code in head section //------------------------------- function av_ga_code_head(){ ?> // Your GA code here. REPLACE THIS LINE WITH YOUR CODE <?php } add_action('wp_head', 'av_ga_code_head');
Best regards,
Yigit -
AuthorPosts
- You must be logged in to reply to this topic.