
How to add google pixel Analytics to your theme
April 17, 2020
There is alot way yo put GA tracking code in your wordpress site, this snippet is how to add the tracking code into function.php file
function add_ga_tracking() {
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-3083399-28"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-123456789-0');
</script>
<?
}
add_action( 'wp_head', 'add_ga_tracking' );
Make sure you change UA code UA-123456789-0 into your code.
Posted in