JSFiddle - React, Tailwind, and code Playground
HTML
<script>
// Create ga global object
window['ga'] = window['ga'] || function() {
// Push all arguments
(window['ga'].q = window['ga'].q || []).push(arguments);
if (arguments[0] == "create") {
ga(function() {
tracker = ga.getAll()[ga.getAll().length - 1];
var clientId = ga.getAll()[0].get('clientId');
ga.getAll()[ga.getAll().length - 1].set('userId', 'ID123');
ga.getAll()[ga.getAll().length - 1].set('dimension1', clientId);
var originalSendHitTask = tracker.get('sendHitTask');
tracker.set('sendHitTask', function(model) {
var payLoad = model.get('hitPayload');
originalSendHitTask(model);
var i = new Image(1, 1);
i.src = "/__utm.gif" + "?" + payLoad;
i.onload = function() {
return;
}
});
}
)
}
}
</script>