Greetings to you the respected visitor on the pages of our site, as you probably already guessed from the title of the article, today we will talk about setting up the goals of Google Analytics.
I have been trying to publish this article for a long time, but everything did not reach my hands, and today we'll talk a little about how to connect Google Analytics goals to the site, what are the goals of Google Analytics, why they are needed, etc. ...
Why did I decide to write this article?
Yes, it's simple, so many users ask me questions about this, they can not connect the goal of Google Analytics to the button of the order, to the feedback buttons, and at all to some page on the site, and today we will try to figure it all out, so that in the future the connection of Google Analytics goals and their configuration was a simple and easy action.
So what are the goals of Google Analytics?
The goal is a certain action of the user on your site that you track for further analysis, it can be as a visit to certain specific pages, or the purpose of pressing the customer for the button to order, the purpose of the callback button, viewing contacts, etc. .
When promoting your site (no matter what subject matter) it is very important to track goals and conversions in order to understand the effectiveness of promotion.
In Google Analytics, you can customize your goals or goal chains, and track both actions and events.
Well, in general, what are the goals on the site and what are they for? I think you understand, well, or you can always turn to the great and mighty Google.
Now I would like to proceed to the most important issue for which I started writing this article, namely setting goals for Google Analytics to the site.
In this article, we will go into details and step-by-step, with pictures and descriptions, consider the connection of Google Analytics goals to the site, as a basis we will take an online store based on opencart.
And so proceed to setting goals:
The first thing you absolutely need to add to the site is the google metric itself, I hope how to add the metric you do not need to explain the site, but if you do not know how to set up the Google Analytics metric then write in the comments we will help, and if such questions will be written a separate article on this issue.
On the site you can apply and use many different purposes of indicators, events, page transitions, but since we are talking about setting goals for Google Analytics in the online store, then for trading I consider the following main goals:
- Goal - Click Buy button
- Goal - Go to Trash
- Goal - Go to Checkout
- Goal - Successful Order Page
All goals are very simple and easy to configure, but such a goal as a buy button or similar goals have some difficulties when installing, especially if you have some third-party modules installed, but we will consider the standard buy button.
Since adding goals for the button to buy the most complex of the described article, then I'll leave it at the very end.
All other goals are simple to install and in principle the same for this with them and start.
1. Set up transition goals (to cart, ordering, successful order, contacts, any other page on the site).
You should immediately understand that any transition leads to a certain page on the site, in our example this is just the pages listed below.
- Go to shopping cart: http://vachsite.com/index.php?route=checkout/cart
- I would like to order: http://vachsite.com/index.php?route=checkout/checkout
- Confirmation: http://vachsite.com/index.php?route=checkout/success
From this example, you can see that the links begin the same way and their difference only in the URL itself, that is, what goes after route =, these are the endings that we will need.
And so to add the goal of Google Analytics first of all, we certainly go to the Google Analytics website and go to the "ADMINISTRATOR" section after which choose a site for which you will add goals (if you have several).
In the third block (View), press the target button.
After clicking on the goal button, we get to the page managing the goals of Google Analytics, where we click on the big red button + GOAL, after the form for adding the goal is opened.
We add the first goal for the site (transition).
There are many different templates in the form of adding a goal that you can use, but in this case we click on own , and click continue.
In the second step of creating a Google Analytics goal, we need to select goal type and goal description , enter a clear target name in the goal description, and since this is a transition, we target page and click on.
Well, on the last point we need to specify the details of the goal, this point is probably the most important, because here you have to determine your goal, here you have the opportunity to choose transition values such as equal, start with or regular expression, if you choose equals, then in the value field, you need to specify a specific full link to the example http://vachsite.com/index.php?route=checkout/cart, if you select the regular expression then you specify and enter exactly the end of the URL (which ie we have defined above in the article) checkout/cart, well, the last starts with, then I think it is clear. The general here be very careful, otherwise the goal will not work, after filling out the form, we'll save it.
Well, in principle, and all that was required to do, all the same thing you do for other pages for which you want to define goals.
Well, now let's get down to the point which is a little more complicated, namely for various buttons on the site, such as buy, order a call and others that are used on the site.
In this example, I remind you that we are doing all the activities on the online store opencart, and now consider the option of adding the event goal to the buy button in the product card.
And so we add the target by pressing the button.
We do everything by analogy as above, that is, create a goal, choose not a template one but own one, and on the second paragraph we choose the type not the target page and event, we specify a clear name, and click next.
On the third paragraph under the event conditions, we need only two values category and action.
Event condition category - this value to which the goal condition will be tied in this case is the purchase button, you can specify any meaning you understand, for example "knopkapay"
Action for event condition - Determines what exactly this category does, since we have this button click to buy, then we write Press.
Well, in principle, and all that we needed to do in the very metric of Google Analytics, I think everything is clear, now let's get down to the most difficult, this is the introduction of the goal into the right button for us to buy.
And so in order for the target to work, we need to add a special code to the button that will google and will understand what needs to be tracked.
The Google Analytics goal code itself looks like this:
onClick="ga('send', 'event', 'knopkapay', 'Press');"
Now we need to go to your site using any FTP manager (I recommend FileZilla), and open the file that contains the code for our button for editing, since we are talking about the online store opencart then you need to open the file that is on the way catalog/view/theme/default/template/product/product.tpl
In this file there is a button code:
<input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" />
and add the Google Analytics goal code to it. so as a result it turned out like this:
<input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" onclick="ga('send', 'event', 'knopkapay', 'Press');">
That is, we added to the button onclick with the target code.
Well, in principle, that's all, now google will understand that click on the buy button you need to track. All your goal for the buy button works.
Error setting Google Analytics Goal to button.
Here, we described how to set a target on a button, but what to do if you already have the the target for example from Yandex in which there is already onclick or what is the template or module in which is present in the button to buy the value of onclick?
In this case, we will need to combine, merge the two codes into one, and they will have the following form:
onClick="yaCounter00000000.reachGoal('button_product'); ga('send', 'event', 'knopkapay', 'Press'); return true;"
Well, the whole button will look like this:
<input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" onClick="yaCounter00000000.reachGoal('button_product'); ga('send', 'event', 'knopkapay', 'Press'); return true;">
This is indicated by the example of the joint work of the Yandex goal and the google goal in one onClick, if you have any other values then we do everything by analogy.
Well, that's all I wanted to write, I hope I painted everything clearly, if that's not clear, ask in the comments, as far as possible we will help.