Cross Domain Tracking
To track visitors with Google Analytics when book now buttons are installed on your website cross-domain tracking needs to be set up. Analytics needs to know visitors will flow from your website to your Trekksoft account by clicking the book now button and completing the booking in the popup. Without cross-domain tracking setup Analytics would see a site visitor that clicks the book now button as a new visitor. So for example, if a visitor clicks a Google ad to get to your website and then completes the booking Analytics would not make the connection that the visitor who clicked the ad was the same visitor that completed a booking. But with a cross-domain tracking setup, it would.
To set up cross-domain tracking first we are going to set up Google Tag Manager (GTM). A free tool, GTM allows managing and deploying of marketing tags (snippets of code or tracking pixels) such as Analytics, Facebook Pixel, Adwords, etc. The installation of GTM is the same as Analytics is, by copying a snippet of code and pasting it into your website source code.
After setting up GTM we will setup Analytics to be deployed from there including the settings necessary to achieve cross-domain tracking. Finally, I will test by going through the booking process and watching the real-time reporting in Analytics.
Google Tag Manager (GTM)
After signing in to Google Tag Manager you will be prompted to create an account and container. Simply give the account a name (for your reference) and select your country. For the container also give it a name, normally the same as your website and for where to use select the web. Finally, click create and agree to the Terms. The Google Tag Manager code snippet will then be displayed. The code is divided into 2 parts, the first should go in the head tag section of your website. The second part goes into the body tag section.
If you are running your website on WordPress, there are many plugins that will allow you to install the GTM code without editing code. Alternatively, you can make a child theme of your existing theme (can also get a plugin to do this). This ensures that if anything goes wrong while working on the code you can default back to the main theme and all will be working as before.
With a child theme created, you can edit the theme files to include the GTM code. In WordPress Admin navigate to the theme editor section and most likely we are looking for the Theme Header file. Then paste the first part of the GTM code snippet to directly under the <head>. Copy the second part of the code and back in WordPress scroll down the page a little and directly under the <body> tag you can paste the second part of the code.
Your Trekksoft account has this feature built-in, we just need to paste the Google Tag Manager ID into the Trekksoft Amin Desk. This can be done by navigating to Design & Pages > Apps > Google. In Chrome, the extension google tag manager assistant can be used to confirm Google tag manager setup is working on both your website & Trekksoft account.
Deploying Analytics from GTM
Now with the Google Tag Manager installed on our website and our Trekksoft Account we can set up Google Analytics. In the GTM, in the left sidebar menu, I am going to select the Variable option. Next, in the User-Defined Variables section click the New button. I will be prompted to select a variable type which will be Google Analytics Settings. Now I will paste in my Analytics Tracking ID and click on the More Settings > Fields to Set. Click the +Add field button, in the Field Name select allowLinker and for the value type true. Now scroll down and we are looking for the Cross-Domain Tracking section. Here for Auto Link Domains, we are going to say what domains we are linked separated by a comma. Eg your-wordpress-site.com, your-tekksoft-acount.trekksoft.com. Now save the Variable.
Now we are going to set up the tag and the trigger, in the left sidebar select Tags and then click the New Button. For the Tag, the Configuration tag type selects Google Analytics - Universal Analytics. For the Google Analytics Settings, we can select the Variable we made before. We could have Not made the variable before and now ticked the Enable overriding settings in this tag box here and the exact same options would be displayed. By making a variable we can reuse it in future tags.
Next, we can click in the Triggering section and for firing, trigger selects All Page Views. This tag will run when any page on both sites is visited. The very last step before testing is to submit the tag (make live). After we can use chrome’s Google Tag Manager assistant to confirm Analytics is set up on both your website and Trekksoft account.
Testing Cross Domain Tracking in Analytics
Now to testing, to test I placed a book now button generated from my test Trekksoft account (Stephens’s Amazing Tours) on a website builder page on a different demo Trekksoft account (called Armonia). The same principles as generating a book now button and placing it on a WordPress site. I will then visit the home page of the demo site, navigate to the page with the book now button. Click the book now button which is the point I move from the demo account (Armonia) to my test account (Stephens’s Amazing Tours). We should see that google analytics sees this as one user. I will then visit the demo account and go through the checkout in Google Chrome’s Incognito Mode, which analytics will register as a different visitor.
Display Domain Names in Url’s in Analytics
You will notice I see the pages that have been visited displayed as https://stephens-amazing-tours.trekksoft.com/en . By default, the domain is excluded which means the URL would display as just /en. To append the domains to these URLs in Analytics navigate to the admin section (cog in the bottom left of the page). Now in the View Column on the right select Filter and then the Add Filter button. We can give this filter a name then for Filter Type select Custom. Next tick the circle beside advanced then add these settings.
Field A: Hostname
Extract A to(.*)
Field B to Request URI
Extract B to (.*)
Output To to Request URI
Constructor to $A1$B1
Then save, and now as if by magic we should see the domains in the URLs.