ROLAND_JUNO Posted November 2, 2017 Share Posted November 2, 2017 Ok I am frustrated guys... I need help? How do I add a BASIC Google Analytics Tracking ID to my Process Wire site?? Something that should be so easy is not. The mods that I found on PW don't work with my PW site so now what? Thanks for any help Link to comment Share on other sites More sharing options...
cstevensjr Posted November 2, 2017 Share Posted November 2, 2017 Hopefully, one of these links helps you with placing your Google Analytics code. https://www.lunametrics.com/blog/2012/02/09/where-put-google-tracking-code/ https://groups.google.com/forum/#!topic/digital-analytics-fundamentals/V9z4TVXQW_4 https://support.google.com/analytics/answer/1008080?hl=en 3 Link to comment Share on other sites More sharing options...
AndZyk Posted November 2, 2017 Share Posted November 2, 2017 Hello @ROLAND_JUNO As mentioned, just put your Google Analytics Tracking-Code before the closing </head> inside your template files. Depending on your template strategy it could be either in an include or a _main.php, so you don't have to put it in every template file. Regards, Andreas 2 Link to comment Share on other sites More sharing options...
rafaoski Posted November 2, 2017 Share Posted November 2, 2017 @ROLAND_JUNO ... Add the code between <! - Google Analytics -> {GOOGLE ANALYTICS CODE} <! - End Google Analytics -> As below and in place UA-XXXXX-Y enter code ( tracking ID ) ... This is an example in _main.php from processwire 3.x ...More info: <?php namespace ProcessWire; // _main.php template file, called after a page’s template file $home = pages()->get('/'); // homepage $siteTitle = 'Regular'; $siteTagline = $home->summary; ?><!DOCTYPE html> <html lang="en"> <head id='html-head'> <!-- Google Analytics --> <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)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-XXXXX-Y', 'auto'); ga('send', 'pageview'); </script> <!-- End Google Analytics --> <!-- THERE ARE EXAMPLES OF PROCESSWIRE 3.X DO NOT COPY THEM --> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title id='html-title'><?=page()->title?></title> <meta name="description" content="<?=page()->summary?>"> <link rel="stylesheet" href="<?=urls()->templates?>styles/main.css"> </head> 2 Link to comment Share on other sites More sharing options...
SamC Posted November 4, 2017 Share Posted November 4, 2017 @ROLAND_JUNO mine is like this. Using the new gtag. Just paste it in as the first item in the <head> section for your site like so: <?php namespace ProcessWire; ?> <!DOCTYPE html> <html lang='en'> <head> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-NUMBER"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-NUMBER'); </script> <!-- then the rest of your meta tage/page title/whatever --> <meta http-equiv='content-type' content='text/html; charset=utf-8' /> <meta name='viewport' content='width=device-width, initial-scale=1' /> </head> You find your specific code (and UA-NUMBER) on the google analytics website. 2 Link to comment Share on other sites More sharing options...
cstevensjr Posted November 4, 2017 Share Posted November 4, 2017 (edited) I hope you have been able to get this working. I will detail how I'm use Google Tag Manager for an upcoming project, just in case you still are having problems. Background I'm working on a new website where we are using an Ecommerce Widget. We normally use Piwik for basic analytics, however this Online Store solution uses Google Analytics to track things (shopping cart, etc). This is where Google Tag Manager becomes a great solution. We ended up using both Piwik and Google Analytics. In Google Tag Manager you create the needed Tags with Firing Triggers. In this situation, we created one for Google Analytics (using Universal Analytics tag) and one for Piwik (using a Custom HTML Tag). The Custom Tag is simple, you enter the Piwik code and save. Now that these tags are created, you take the Google Tag Manager code and add it to your website. Just follow the instructions, as listed. My website configuration has a _head.inc and _main.inc. You can see (above in the 2 files) where the Google Tag Manager code is put. It turns out to be a very clean solution when you need to track many things or have more than one analytical tool that needs to track things. One of the good things about using Google Tag Manager is that you can verify that the 2 Tags are firing, as you need them to. Additionally, you can create more Tags to track a multitude of things on your website. Google provides free training courses on Google Tag Manager, if you are interested: https://analytics.google.com/analytics/academy/ I hope this helps someone out. Edited November 5, 2017 by cstevensjr Added link for Google Tag Manager Training 7 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now