How to Implement Event Tracking
There are two main ways to configure event tracking in MVMCloud Analytics. The first is with the Tag Manager integrated into MVMCloud Analytics. The second is to add JavaScript code snippets to your own website. You can find more details on how to configure both methods below.
How to Configure Event Tracking with MVMCloud Analytics Tag Manager (recommended)
Tag Manager is the easiest way to implement event tracking on your website. You can simply create a Tag for each type of event you want to track. Below you will find an example of Step-by-step guide to creating an event that tracks email link clicks on your website.
- Configure MVMCloud Analytics Tag Manager (create a container and install the container code);
- Click on Tag Manager in MVMCloud Analytics and visit the Tags page;
- Click on the big Create new tag button;
- Select the tag type MVMCloud Analytics;
- Give your tag a descriptive name. For example; Event – Click on the link in the email;
- Confirm your MVMCloud Analytics configuration. If you are unsure, use the default setting;
- In Tracking Type choose Event;
- You are now ready to add your event structure in the next fields. Following our example, it would look like this:
- Event Category: Contact;
- Event Action: Click on the link in the email;
- Event Name: {{ ClickDestinationUrl }};
- Event Value: Note: In the example above, the event name is dynamically populated from a Tag Manager variable that extracts data from the website itself. You can search for them by the square code icon next to the field.
- The next step is to select your Trigger. Click the link to Create a new trigger now, which will display several options. For this example, you would select Click all links in the Click section, which will display options to customize which links to track as events.
- For this example, you can use all email links as the trigger name.
- To limit the trigger to specifically target email links, you will need to add some details to the Only fire when (optional) section.
These steps will ensure that only email links are counted:
- Select Click destination URL in the first field;
- Select Starts with for the second field;
- Enter mailto: in the last field which is the prefix used to create email links;
- Finish the trigger by clicking the big button to Create new trigger.
- Now that the trigger is attached to the Tag settings, you can click Create New Tag.
- Finally, you will need to publish your container. You can do this from the success message that appears when you create a new tag or by selecting Publish in the left menu.
- Once your new event tracking tag is active, you should test that it is working. To do this,
visit their website and click on an email link. Then log in to MVMCloud Analytics, go to the Visitors section and click to view the Visit Log.
This allows you to review visits in real time and you will be able to see your visit with the event shown on the right side.
How to Configure MVMCloud Analytics Event Tracing with JavaScript
The second method of setting up event tracking requires a little more technical confidence. You will need to integrate a JavaScript snippet directly in your website code. Links are one of the most common elements to integrate with event tracking.
JavaScript offers a function called onClick that you can add to your links. A standard HTML link looks a little like this:
Send Email
Links in HTML contain the base tag a and several attributes, including the link defined in href . You can extend HTML links with the JavaScript's onClick function so they look a little like this:
Send Email
As you can see above, the code follows basically the same format as the first link above, but with an additional onclick attribute. The actual JavaScript function that raises the event is enclosed in quotation marks. The example above would be:
_paq.push(['trackEvent', 'Contact', 'Email Link Click', '[email protected]']);
The code example above tracks the following event data:
- Event Category: Contact
- Event Action: Email Link Click
- Event Name: [email protected]
It works by telling MVMCloud Analytics that you want to send data to the platform _paq.push([ ]); and trackEvent defines the type of data to be sent. The MVMCloud Analytics then recognizes the next two to four attributes as from the Event; Event Category, Action, Name, Value.
You may have also noticed that the code above only shows three values after trackEvent. This is because the Event Value attribute is optional. If a Name or Value is not necessary, you can simply leave out the final parameters instead of adding them blank. To get a example of an event where you want to track a value, see below:
_paq.push(['trackEvent', 'Ecommerce', 'Add to wishlist', 'Smartphone', 1000]);
The code example above tracks when an item is added to a wish list, with the value set to the cost of the item:
- Event Category: Ecommerce
- Event Action: Add to wish list
- Event Name: Smartphone
- Event Value: 1000
You may notice that because the value is a number, it does not require single quotes like the previous text strings.