Setting up Goals in Google Analytics for your Drupal site

soccer goal and goalie

"Setting goals is the first step in turning the invisible into the visible."
- Tony Robbins

Quick - what percentage of all the visitors to your website use your Contact Us page to request more information? On your "Download our Guide to Norwegian Cheeses" landing page, how many people give you their information and submit the form, and how many aren't convinced and decide to get their Norway cheese info somewhere else? Are those numbers going up ... or going down?

You can't tell how well your page design and marketing efforts are working if you aren't measuring goals and conversions. Fortunately for Drupal sites, with a little help from Google it's easy to do.

Let's start with your Contact Us page, and assume you are using the core Contact module. If not, first set one up. You will also need to set up Google Analyticsand the related Drupal module if not already installed. Once those are working, head over to Google Analytics, click on Access Google Analytics on the upper right side, select your website and All Web Site Data to get to your home Analytics page. Look under Conversions >> Goals >> Overview to see all your configured goals ... which at the moment is likely none.

First step in setting up goals in Google Analytics

So let's set some up by clicking on theSet up goals button. You should see this:

Click on +New Goal. Google Analytics provides many templates for configuring your goal - chooseContact us and thenNext Step. You should then see this:

Step 2 of configuring a goal in Google Analytics

It is asking you to configurehow you will consider this goal met. The default type, and only one that makes sense for our Contact Us page isDestination, meaning that Google Analytics will consider the goal met when the user visits a certain page. Specifically we need athank-you page - a page that is only reached after the user submits the Contact Us form. We can't use the URL of the Contact Us page itself - that only tells us that the user viewed that page, not that she submitted it. After she clicks theSend Message button, she should then be shown a new page that thanks her for sending the message, and perhaps has some additional sales and marketing info on it. But the important thing is that it is a different page, so we can track it.

Which is now a problem for us, as the Drupal core Contact module doesn't have the option to specify aredirect page that the site viewer is shown after submitting the Contact Us form. When a user submits the form, she simply sees a standard green Drupal status message and stays on the Contact Us page, like this:

Not an especially good User Experience, and more importantly, it doesn't give us what we need to trigger the goal. Adding that important functionality has been discussed for many years, and there is work going on now to put it into Drupal 8 ... but what do we do for all our Drupal 8 sites now? We could use the Webform module to create our Contact Us page, which does have the redirect page option as well as many other additional features, but at the cost of higher complexity and effort to implement.

Fortunately there is a perfect module that adds just the functionality we need - Contact Plus. Install in your preferred manner. Now, when we edit our sitewide contact form (Structure ยป Contact form >> Edit), we see a new configuration field forRedirect path.

The default is to redirect to the front page, but that isn't useful. Instead, create a newBasic Page that thanks the site user for submitting her info, promising them to get back to her shortly, and any other marketing messages you may want. Set the URL to something like http://yoursitename.com/thank-you-for-contacting-us. Put that entire URL into theRedirect path field (the module can't handle a relative path unfortunately) and save.

We now have what we need to finish configuring our goal in Google Analytics. Go back to that browser tab, make sureDestination is selected and clickNext step.

Enter just the relative path of your thank-you URL (the part after the site name) and click Create Goal. You can leave the other advanced options set to off. If you use a social tracking system that adds more characters to the end of all your website URLs (like ?JK8uejshl), then change Equals to toBegins with or your goal won't trigger.

We are done! Well, except for viewing the results on Google Analytics, which right now there won't be any. Run a test on your Contact Us form, wait a day or so for Google Analytics to record the event, then check back at Google Analytics,Conversions >> Goals >> Overview to see your goal completion data. We will go into more advanced Goals and Conversions methods in a future blog post, but for now you working toward a goal.

And be sure to use the FireRoad Digital Contact Us form to see what you get after pressing Send Message!