How to organize ABn testing through Tag Manager

Step 1: Create your own events in Google Analytics

Step 2: Create a sending code

_gaq.push(['_trackEvent', 'category', 'action', 'opt_label', 'opt_value', 'opt_noninteraction']);
onclick
<button id="my_btn" onclick="_gaq.push(['_trackEvent', 'category', 'action', 'opt_label', 'opt_value', 'opt_noninteraction']);">My Button</button>
var TransferBtn = document.getElementById("transfer");
TransferBtn.onclick = (function() {
_gaq.push(['_trackEvent', 'category', 'action', 'opt_label', 'opt_value', 'opt_noninteraction'])
})();

This was the hitch that led to the writing of this article. Because there is only one article on the Internet that indirectly talks about this situation, which can happen to any employee who gets a job to “fix the Internet” in a huge company.

Step 3: How to send data to GA through the dataLayer

Step 4: Complete the listening code and publish it in the Google Tag Manager container

var TransferBtn = document.getElementById("transfer");
TransferBtn.onclick = (function() {
_gaq.push(['_trackEvent', 'category', 'action', 'opt_label', 'opt_value', 'opt_noninteraction'])
})();
dataLayer.push({‘event’: ‘event-to-ga‘, ‘eventCategory’ : ‘category_value’, ‘eventAction’ : ‘action_value’, ‘eventLabel’ : ‘label_value’, ‘eventValue’ : ‘value_value’ });

Step 5: Checking that the code works

How to organize ABn testing through Tag Manager

--

--

UI designer who codes on a freelance basis. I’m on my way to become a UX (Product Designer) in a large company.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store