Can we add a Google tag code and a Google Analytics code under the enfold theme -> Google Analytics box?
Hey amyncuih,
Thank you for the inquiry.
Yes, you can add both embed codes in the Google Analytics field or use hooks such as wp_head if you want to separate the Google Tag embed code.
Example:
function ava_add_google_tag_code() {
?>
<!-- Google Tag Embed Code -->
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TAG_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'YOUR_TAG_ID');
</script>
<?php
}
add_action('wp_head', 'ava_add_google_tag_code');
More info: https://developer.wordpress.org/reference/hooks/wp_head/
Best regards,
Ismael
How do I add both codes? with a comma?