Blog

retailCRM and Google Analytics integration - as simple as “2x2”

retailCRM can download data about client’s viewed goods and pages, sources income, channels, campaigns, reached events and aims from Google Analytics. This is used in retailCRM for…
retailCRM 4 Mar 2016

Here are several examples of triggers, which you can adjust after GA and retailCRM synchronization:

Example №1:

In case if a constant customer visited site, but didn’t buy anything, send an e-mail 24 hours after. Include in e-mail goods, which user was interested in most of the time during his visit.

Example №2:

Send e-mails to clients, who entered website’s blog section a day ago, and read articles, dedicated to N product.

In this article we will show you how to create and adjust retailCRM and Google Analytics bundle on a forshina.ru eStore example.

How to adjust Google Analytics and retailCRM bundle?

So, here’s the toolset:

  • Google Analytics account
  • retailCRM account
  • FTP-client to access site source files

We begin the adjustment with entering the retailCRM administration panel. Upon there choose “Integration”, “Web analytics” section. Here you will see a single module - Universal Analytics, enter it and copy the username. In our case it looks as:

retailCRM-service-account@tough-messenger-114112.iam.gserviceaccount.com

Now go to the GA account, “Admin” section. Find “User Management” subparagraph on the left side and click on it. Insert the earlier copied name in the field “Add permissions for” and set “Read & Analyze” privileges for it, click “Add”.

After you have added a new user, go to “View Settings”. Here fill in “Website's URL(insert address of your internet-store) and set currency used in eStore. Save.

Return and click “Ecommerce settings”. Inside the section set the slider “Status” to “ON”, and leave “Related Products” as it is. Save.

Go to Google Analytics main page, Admin section, and click “Custom Definitions”. Choose “Custom Dimensions” from the dropping list. Create a new custom dimension named retailCRMVisitorID and remember the index that will be given to it. In our example the index equals 1.

The next step we are to do is to fill in the data in Order management system. We return to Universal Analytics settings, and fill in the following fields:

  • Profile ID. You must get the identificator itself in “View Settings” in GA admin section. “View Identificator” is the profile ID we need. Copy it and paste in retailCRM field.
  • Parameter Index - it is the retailCRMVisitorID and it equals 1 in our example. That’s why we put “1” in the field.
  • Tracking Identificator - we get it in GA Admin section, “Property Settings” part. The value of UA-XXXXXXXX-X type is the tracking ID. Copy it and paste to retailCRM field.

In the dropping list “Relate transactions through” select “order number”, tick “Enabled” and save.

Here on, the Order management system and Google Analytics bundle is adjusted. Let’s now setup connection with the eStore itself. To do this we will add GA script to the site. The script consists of two parts:

You should put the first part of the script in all the site pages, it will register client visits:

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'tracking identificator', 'auto');

  function getCookie(name) {
    var matches = document.cookie.match(new RegExp(
        "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" 
    ));

    return matches ? decodeURIComponent(matches[1]) : "";
 }

  ga('set', 'dimension1', getCookie("_ga"));
  ga('require', 'displayfeatures'); 
  ga('send', 'pageview');

/* Accurate bounce rate by time */
if (!document.referrer ||
     document.referrer.split('/')[2].indexOf(location.hostname) != 0)
 setTimeout(function(){
 ga('send', 'event', 'New visitor', location.pathname);
 }, 15000);
  ga('send', 'pageview');

</script>

Go to FTP-client, get access to the root site directory and find files responsible for <head> section. In our example it is «head.tpl.html» file. Paste the script to any code field.

Put parameter index in the 'dimension' parameter. In our case it equalled to 1, that’s why in our script 'dimension' will look like 'dimension1'. Save the file.

Now all the clients and their visits will be saved on our site, and all the statistics will be displayed in analytics.

The second part of the script will be added to the successful order registration page. The script will be creating a transaction with the required ID and sending it to GA.

<script type="text/javascript">
 ga('require', 'ecommerce', 'ecommerce.js');
  ga('ecommerce:addTransaction', {
    'id': {{order.number}}
  });
  ga('ecommerce:send');
</script>

Find file pattern on FTP responsible for the successful order registration. It’s called «order4_confirmation_quick.tpl.html» in our case. Add the script to any part of the file.

Do not forget to give the number of order, registered on site, to the 'id'variable. Here’s how it’s written in the code in our case:

'id': {/literal}{$orderidd}{literal}

Now, all the order sources, client visits and his statistics data will be collected, after the client registers an order. 

All this data will be automatically collected in retailCRM order section 6 hours after.

Pay attention - if you want to get the best of your retailCRM functionality, bundled with GA, it’s not enough to simply set a GA code. You need an e-trade module (simple or extended) to be adjusted.

comments powered by HyperComments