Avatar of Sarah Ward
Sarah Ward
Flag for United States of America

asked on 

Google Analytics / JavaScript: Get Client ID

I'm working in WordPress and I have this block of JS code on my page. I'm trying to write the Google Analytic Client ID in the console, however, I'm getting the following console error:

Uncaught ReferenceError: ga is not defined


<script>

    ga('create', 'UA-123456789-1', 'auto');
    ga('send', 'pageview');
    
    ga(function(tracker) {
      console.log(tracker.get('clientId'));
      /* Your other code here */
    });

</script>

Open in new window


What am I missing?  Any help would be appreciated.  Thanks!
GoogleJavaScriptAnalyticsWordPress

Avatar of undefined
Last Comment
Michel Plungjan

8/22/2022 - Mon