// Function to add Google Analytics
function add_google_analytics() {
?>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script> // 替换你的ID
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID'); // 替换你的ID
</script>
<!-- End Google Analytics -->
<?php
}
add_action('wp_head', 'add_google_analytics');