Skip to content

Instantly share code, notes, and snippets.

Focusing on learning something every day

Matthew Harris rtpHarry

Focusing on learning something every day
View GitHub Profile
rtpHarry / WordPress Google Analytics
Last active Mar 16, 2019 — forked from kenhowardpdx/WordPress Google Analytics
Add Google Analytics to WordPress Theme functions.php
View WordPress Google Analytics
// originally based on
// updated to current gtag.js snippet and moved to head
function rtp_init_analytics() {
$analytics_id = 'YOUR UA CODE HERE';
$analytics = '<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="'. $analytics_id .'"></script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}