Implementing CPA affiliate purchases in GTM enhanced ecommerce - javascript

I'm implementing Enhanced Ecommerce on our (mainly affiliate) website through GTM. We have list views and detail views etc.. so implementing impressions and clicks is easy, but for affiliate purchases there is a problem.
We have two payment models for the shops that are showing their products on our site:
Cost per Click. I can implement a small purchase on the clickout page.
Cost per Acquisition. Here is the problem: The purchases are made on a different website on a different time. Using PHP API's I get the purchases made a few times a day through a cronjob.
How can I create a purchase (preferably using PHP, using javascript is messy on a cronjob) but retain the cookie value so I can link the purchase to the clickout and channel people used to get on our site.
I thought of creating all zero purchases for each clickout and maybe repurchase using the same transaction ID. This might work, but we will end up with thousands of empty purchases.

I ran across a similar problem a while back. Our checkout lives on a different domain. So when Adwords people would checkout after migrating to Universal, I was losing that data at checkout. I think my solution there could help you. This all assumed you're using Universal Analytics and not the old deprecated libraries.
The first thing I do is grab the GA cookie, which is named _ga. Inside it is your GA session. It looks like this (it will be much longer)
GA1.2.3456.7890
The third and fourth number sets (including the period) are the session itself. Parse them out.
Now you want to find some way to store this with the user. I used my PHP session (we pass it in the query string when we jump domains) and stored it there. You'll have to figure something out that works for you here.
On the other site we need to specify the GA session and site within the GA block. Please note that the new site will report these visits as if they belonged to the original site. The UA-XXXX-Y should be from the original site and yourdomain.com should be the new site TLD
ga('create', 'UA-XXXX-Y', { 'cookieDomain': 'yourdomain.com', 'clientId': '3456.7890' });
Now you can pass your purchase metrics in. When a session converts on the new site, the old site will track it, along with any other things that session held (i.e. page impressions, Adwords clicks, etc.). You don't need any messy cron jobs to do this. Just be aware, as I said earlier, that these page visits belong to the original site as far as GA goes. You could try reporting two sets of metrics to get around this, but I have not tried that.

Reading the comment beneath the answer from Machavity, i assume that you are using Universal Analytics, or else Universal Analytics is the way to go!
I have had a case in the past where we had to think of a one way tracking system because we didn't have access to the other site's code.
Give a look at the Google Measurement protocol. This protocol makes it possible to send raw userdata directly to google analytics over HTTP.
Link to Google measurement protocol

Related

How to track Facebook sale traffic in GA (gtag.js)?

Google analytics actually shows that payment gateway is the source of traffic that brings in the sale, which of course is triggered by the fact that they leave my website to pay and then it comes back to my website to place an order.
I was wondering if there is any ways to track the customers from where they come from (such as Facebook page) and if you have any suggested workaround. I want to track where the sales is coming from and this is making it a little hard for me.
For now, I have implemented the tracking code GA (gtag.js) in my website, but all I see is just it track the source within the website as if user click product category A to category B based on this tutorial https://developers.google.com/analytics/devguides/collection/gtagjs/.
I do some research about cross domain tracking here https://developers.google.com/analytics/devguides/collection/gtagjs/cross-domain, but where do I find the linker parameter? Does this tutorial will help to solve my problem?
One more, do I need to do anything with Google Tag Manager and Adwords?
Really need help, thank you :)
Check that your payment gateway is included in the referral exclusion list. In that case it should be ignored and the original traffic source should be retained (unless the redirect parameter adds campaign parameters of his own).
Cross domain tracking is not appropriate here. Cross domain tracking means to have a continuous session over multiple domains, which requires that your tracking code is placed on all the domains.

Google analytics - difference between analytics data and the data from the core platform

We use Google analytics with Google Tag manager for our ecommerce platform based to track the conversion, etc.,
In the thank you page, its used to track the order value and the revenues.
Consistently we see a difference of about 15 to 20 % difference between GA data and the data from the core platform.
Tried to find a pattern among the missed orders but couldnĀ“t ascertain one easily. The GA recorded orders include devices like Desktop, tablet and mobile and we see different browsers too.
Need inputs to analyze this better.
Note: Thank you page is loaded by a redirect from the payment gateway system
15-20% difference is not good at all. Google says you should expect better than 95% accuracy, and to keep at it if you're not getting those numbers.
Note: The more "techy" crowd that your website has, the more folks you'll run into "Do not track" or with Ad-Blocking tech in their browser. Normally, you'd want to try to baseline that difference using device category filters to see if the gap is bigger for desktop (most phones/tablets don't use ad-blocking).
First, question. If the user lands on the thankyou page, and hits the refresh button, does it send another "conversion" to GA? IF so, you want to make sure that you build in logic that prevents duplicate conversions to be sent if the user was not making duplicate purchases. A browser refresh is not a purchase, don't record it as such.
Second, if the page takes forever to load, or you have users that have bad internet, then that could increase the difference. They might be closing the browser or exiting site before GA client has a chance to send the final conversion to the server. So how is the performance of your thankyou page?
Are you sure you're looking at the correct business data? I've been told GA numbers are off by the business before and it turned out they messed up their own query in the transaction system (and they had been doing so for years!). It is a long shot, but if you feel super confident about your GA measurement setup, then run it by the folks giving you the transaction numbers.
Finally, if you can't get the difference down then move to the Measurement Protocol server-side implementation of GA. You simply need to record the IP address of the user and their GA client id, and then construct an HTTPS GET request using the Measurement Protocol fields for a valid hit. Server side measurement is the most accurate way to do this, but requires code updates in the ecommerce platform itself.

Organic vs Paid traffic in Javascript

Is there a way to (in Javascript+jQuery), extract the data of whether a visitor is Paid vs. Organic traffic (or other such metrics)?
For the scope of the question, you can assume that Universal Analytics is running on the landingpage, but I'm limited to console-level Javascript only.
Little background: For a test we want to run, we're looking to target different visitors in different ways in a sort of tag manager-tool. The tool limits us to only using Javascript, so we can not directly use the information from Analytics.
I've seen this question. However, that question appears to be outdated, because (as is written in the comments of the answer), the answer does not work with UA.
This information is available in Analytics, so you'd think they'd be able to retrieve it from somewhere. My question is, could I find this information through Javascript?
You can identify the traffic on the landingpage, since with UA paid traffic either needs to have a gclid (a Google click id from Google Adwords) or campaign parameters ("utm parameters", most notably utm_campaign) that identify if this is a paid channel. Then you'd have to store the information via a cookie or localstorage.
Other than that the Universal Analytics tracking code will not reveal anything about the visitor except the client id, which says nothing about paid vs. organic.
For completeness sake: In theory you could store client ids as a custom dimension in GA and use the API to create a service that let's you retrieve information about a given client id via an ajax call, but that would have a certain lag (since GA needs a few hours before it has processed data for a visit), would probably not be very efficient and might have privacy implications that might put you at odds with the Google TOS and national laws.

Add UTM parameter based on events

I know that it's best to add Google Analytics UTM parameters externally for incoming campaign traffic.
However, when dealing with a juggernaut of an IT team who like to say "no" a lot I'd like to attempt to arm myself with a solid response. Analysts will feel my pain in trying to convince others to track campaigns the correctly, rather than by listening to a non analytics users advice of just creating segments based on URLs.
There will be a campaign running where a visitor to the website will input a promo code in order to get a free thing.
For whatever reason we cannot tag the incoming traffic or the links that will lead from the promo source with our UTM parameters.
I can create an event in GA for when a visitor enters a promo code that relates to the campaign in question - the URL generated will contain the promo code int he URL, thus allowing me to create an event.
Is it possible in Google-Analytics, combined with a lateral thinking developer, to overwrite the UTM parameters based upon a click event halfway through the visitor session? Could a script do this?
Any other ways around it?
We do have Google-Tag-Manager at our disposal too.
Doug,
Sorry to dissapoint you, but any overwriting based on events (or any single-hit action by user) won't work correctly and would lead to skewing your data anyway. See this brilliant post by Joshua.
What you could do however is to use CustomVar or CustomDimension (on session level probably), which would substitute UTM parameters. So if there is a promo on your werbsite, you can assign some value after users click on it.
Then by building a custom report, you should be able to use this with no restrictions, just instead of medium/source pick your customvar/customdim.
Hope this helps.

Is there a cross browser way to turn off cookies using Javascript?

Everyone of us knows the new law which is a pain for developers who are using cookies on their websites.
We have to ask our users if they allow us to create cookies on their machines. If they won't allow us this thing, how do we turn off cookies with javascript?
Is there a way to turn off cookies just for one website? Is there a compatible script which will work for all browsers?
What about 3rd parties cookies (Youtube, or Google Analytics? They are also stored in our website folder..)
Thank you!
You can't turn off cookies from the client. Your client code can stop creating new cookies, but even then the server could still be putting cookies on the page. If you want to stop creating cookies for a particular site, then you need to stop doing so in both your client code and your server code.
FYI, is it really cookies-per-se that are the problem - or is it more what you do with those cookies (like tracking a given user). For example, if you set a cookie just to remember what tab the current user was last on (with no other identifying information in the cookie and no use of that cookie on the server), is that a problem? Or, a cookie that stores a temporary session ID so that the server can keep track of the items in your shopping cart. I doubt these are issues because these aren't tracking or privacy issues.
As every country has their own laws in regard to this, if you are aiming for compliance with a particular country's laws, you will have to consult their exact laws.
I have no idea what all the different laws are across different countries, but the Dutch cookielaws aren't all that strict and most sites won't have to change a thing. You might want to look into the exact laws that apply to your website before you try to purge all cookie creations from it.
In short Dutch cookielaws come down to:
A website must ask permission to place cookies that track the user (this includes 3rd party cookies, such as cookies added by Google).
A website doesn't need to ask users for permission to place cookies that are required to run the website. An example of such a cookie is a cookie that keeps track of what you placed in your shopping cart.
Most implementations of this law that I have seen so far are similar to the one found on fok.nl. The first time the user opens the site a large popup is thrown into their face that will only let the user open the real website if they permit the site to place cookies. I assume this setting is then stored in a new cookie so the user never gets bothered with it again. This solution shouldn't be too difficult to implement.
Edit:
Here are some more examples of implementations: http://www.stormmc.nl/nieuws/nederlandse-voorbeelden-implementatie-cookiewet/ (just click the links).

Categories