I am new to google analytics tag, I am sending event on click, now I have added data-consent as you can see below my script tag in a header.
Tag
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>my app</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async type="text/plain" data-consent-category="3" src="gtagjs link"></script>
<script type="text/plain" data-consent-category="3">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'my code');
</script>
Sending event to GTA
if(gtag){
console.log('GTA IS LOADED');
gtag('event', "take_test", {
'event_category': "engagement",
'event_label': labela,
});
}else{
console.log('NO GTA IS NOT LOADED');
}
When I run my app I get the following
gtag is not defined