I'm trying to register source and medium impressions using the Google Analytics Measurement Protocol.
I'm not seeing pageviews or source/mediums being recorded in the GA dashboard.
I'm running this snippet in my head tag.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
var randomid = Math.floor(Math.random() * 1000000);
var path = window.location.pathname;
var pathuri = encodeURIComponent(window.location.pathname)
var url = 'https://www.google-analytics.com/collect?v=1&tid=UA-XXXXXXXX-X&cid='+randomid+'&t=pageview&cs=tvstest3&cm=ctvtest3&dp='+pathuri;
$.post(url, function(data, status){
console.log("Data: " + data + "\nStatus: " + status);
});
</script>
Which results in a network call of
https://www.google-analytics.com/collect?v=1&tid=UA-XXXXXX-X&cid=537396&t=pageview&cs=tvstest3&cm=ctvtest3&dp=%2Ftest3.html
https://ga-dev-tools.appspot.com/hit-builder/ returns "Hit is valid!"
and if I send the request to https://www.google-analytics.com/debug/collect
Data: {
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ ],
"hit": "/debug/collect?v=1\u0026tid=UA-XXXXXXX-X\u0026cid=521292\u0026t=pageview\u0026cs=tvstest3\u0026cm=ctvtest3\u0026dp=%2Ftest3.html"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
}
Status: success
Can anyone shed some light on why I'm not seeing pageviews and source/medium being recorded.
Thanks!
-cwmacken
If bot filtering in your view is enabled the hit may not be recorded. This is because using the Measurement protocol data protocol looks a lot like a bot injecting data into your property.
Try to disable this checkbox in your View settings: