Skip to content

Instantly share code, notes, and snippets.

@teej043
teej043 / ga-acf.php
Last active April 11, 2019 10:17
Create Google Analytics field and output with ACF
<!-- Google Analytics -->
<?php
$ga = get_field('site_analytics_ga', 'option');
if ($ga['tracking_code']) :
?>
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)