Sunday, October 20, 2019

Drupal 7 / Ubercart 7 - Integrate Web-Stat Tracking & Analytics

Drupal core 7.67 / Ubercart 7.x-3.13

Now that we are close to going live with the site, it's time to start installing analytics and profiling software on the site so we can get an idea of who is coming, how long they are staying and what they are looking at - as well as what device(s) they are using to access us, to help us understand whether or not the migration to mobile-centric made sense in the end.

Here's the web-stat html snippet that needs to go in the footer of every user-oriented page on the site:

This code snippet needs to be added to a block, which would then be assigned to the Footer area of every user-oriented page, enabling web-stat to do its thing.

Here's how you add a block:

Here's how you configure a block for interpretation as PHP code:

There's a couple of ways to enable PHP Processing on a Drupal 7 site:

1) You can create a custom block containing the webstat code in the Drupal GUI 
2) You can Insert the webstat code directly into page templates 

The slower, but more elegant way is #2.  Add a custom block with code in it in the Admnistration GUI.  This also enables you to apply selective filtering to the custom block so your use of administration pages don't appear in the web-stat tracking reports.

OK, we create the block:

A few things to note here:

  • Block title should be empty - because this is an "invisible" feature
  • The Text format must be set to CKEditor
  • The CKEditor Source button must be activated, because we are entering raw HTML
Now, place the configured web-stat block in the Content Top area of the website design, for now:

Finally, we want to filter out this block from administrative pages of the website, so we only track user activity:

Flush all caches, to ensure that Drupal 7 serves out a fresh version of all content, including the webstat tracking code in the Content Top area of the page:

Reload a user page (like the home page) using CTRL-F5:

Load the page source code using RIGHT-CLICK:

Search the page source to see if the WEB-STAT code appears 


No comments:

Post a Comment