Envato Elite Authors – Know where your sales are coming from

Since our presence on Themeforest market 5 years ago, we have been looking to be elite authors to gain the access to Google Analytics data and then we will be able to identify where the sales of our themes are coming from.

Unnamed image

 

Problem

The shocking thing was that there is no linking between both domains “themeforest.net” and our domain “creiden.com” which leads to 2 issues :

 

1- Suppose the following scenario: a user lands on our domain avaris.themes.creiden.com referred by XYZ site, and then lands to Themeforest and purchased our theme. In this case the referral is totally lost, we’ll never know which referral is bringing the sale to us ? and we’ll never know the behavior of the customer who made the purchase, just nothing !

 

2- The other Scenario: a user lands on themeforest.net referred by XYZ site, and then lands on our domain avaris.themes.creiden.com and then lands back to Themeforest. In this case we can get that this user who is coming from site XYZ has purchased the theme. This is good despite that this user’s flow was interrupted when (s)he visited our domain, and so we can’t track the behavior of the visitors who are coming to our domain.

 

Details of the problem

Google Analytics depends mainly on the _ga parameter stored in your cookie in order to identify if the user is in the same session or using a different session, and for sure since Themeforest and our domain are identified to Google analytics as two different separate domains; cookies generated for both sites are not identical. So there must be a way to transfer those cookies between both domains.

Screenshot for Themeforest domain _ga cookie :

themeforest-cookie

Screenshot for our domain _ga cookie :

creiden-cookie

 

As you can see both cookies are different in value which means that the same user is recognized as 2 different users for Google analytics which leads to losing the referral path or the usage behavior of your customer.

 

Solution

Fortunately, Google Analytics has addressed this issue by allowing to transfer this cookie between multiple domains through sending the _ga (Linker Parameter) in the URL as a query parameter, and once you land on the other domain this cookie is fetched automatically from Google analytics auto linker and then the cookie is unified in both domains, you can refer to this article for more details

We will discuss the solution for both cases in the following points, however generally you will need to this add code to your domain:
ga('create','UA-XXXXXXX-Y', 'auto', {
allowLinker: true
});
ga('require', 'linker');
ga('linker:autoLink', ['themeforest.net', 'preview.themeforest.net', 'creiden.com', 'any other subdomain']);

instead of just
ga('create', 'UA-XXXXXXX-Y', 'example-1.com');

Case 1 Solution – A user is landing on our domain then navigating to Themeforest:

This case will be solved automatically by just adding allowlinker : true as described above, you will find all the links that is pointing to Themeforest are modified and contains the _ga parameter as you can see in the below screenshots

Our Domain _ga Cookie:

creiden-cookie

Themeforest _ga Cookie:

creiden-themeforest-cookie

 

This means that your _ga parameter is correctly sent and the cookie is modified as well so that the user is still with the same client id.

 

Case 2 Solution – A user is landing on Themeforest then navigating to our domain:

This case has some tricks to be solved:

Envato is sending the _ga parameter to its new link “preview.themeforest.net” and accidentally when Google analytics linker sees that you are activating the linker between sub-domains and you are navigating between your sub-domains it appends the _ga parameter to its links.

So if you clicked on live preview of any theme you should see the link like this before redirection: http://preview.themeforest.net/item/avaris-responsive-wordpress-multipurpose-theme/full_screen_preview/16543524?_ga=1.167490874.587306603.1468xxxxxx

4omlb

but the bad part is that your theme is inside an iframe in this sub-domain so the _ga parameter can’t be accessed with JS

One of the solutions for this problem is to grab the _ga parameter with PHP $_SERVER[‘HTTP_REFERER’] and append this parameter to the JS redirect to your theme, like the following:


// Function that gets the parameter by name
function getParameterByName(name, url) {
// the url is identified from the http_referrer
if (!url) url = "<?php echo $_SERVER['HTTP_REFERER'] ?>";
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var ga = getParameterByName('_ga') ? '?_ga=' + getParameterByName('_ga') : '';
// append the parameter to your link and redirect
window.top.location.href = "https://avaris.themes.creiden.com/" + ga;

Note: Envato was sending the _ga till 2 weeks before now and then it just disappeared, I asked DTBaker to contact them and they have fixed the problem, hopefully we will see it back again after few days

 

Seeing the data in Google Analytics:

One of the ways of checking your data and see the source of the sale is using the User Explorer, and since the customer data is linked now across multiple sessions as described above then it is now possible

The result will be something like the following

referral-sale-explorer

Conclusion

In all cases, you can still link many domains if only you have access to append the _ga parameter to the URL of the destination with both domains having the allowLinker set to true and allowing to take parameter from the source domain

I hope you benefit from this post and GLWS :)

  • http://www.pirenko.com Pirenko

    Thanks for sharing! I’ve been looking for this since I can remember 😉

  • https://www.proteusthemes.com Primož Cigler

    Excellent writeup. I was very skeptical at the beginning when I saw the title, because I was trying too hard in the past to link the tf with demo pages and it was not possible. However, now that the TF has changed the analytics code and added the _ga to the demo preview link, it is possible. I will implement this within next days on our preview bar: https://github.com/proteusthemes/themeforest-preview-bar

Want to increase your sales?, Follow these steps and get your business a step further
Check Now

Want to see your business Elevated?

Hire Us