-
Successful Tracking of Google Analytics Events with Selenium Using C#
“Hey folks, I’m messing around with a project where I’m trying to snag some Google Analytics events from the network logs of an ecommerce site. When I do it old school and manually track things down, I see the events no problem, but when I automate it with Chrome, the events are putting on their cloaks of invisibility (meaning, I don’t see ’em at all).
Just so you know what I’ve already done, I’ve got my network logs and performance logs switched on. Should I be looking at some other settings that need to be flipped or do I have to do some tweaking somewhere else? Seriously, any tips would be a huge help, guys. Thumbs-up emoji!
Oh, and here’s my code if you want to layer in the technical bit:
`
public bool GAEventslogs(string gaEvent)
{
var logs = Site.Driver.Manage().Logs.GetLog(“performance”);
for (int i = 0; i < logs.Count; i++)
{
Console.WriteLine(logs[i].Message);
if (logs[i].Message.Contains("https://analytics.google.com/g/collect"😉 && logs[i].Message.Contains(gaEvent))
{
return true;
}
}
return false;
}
`
And if it helps, here’s a link to the GA events that I’ve been able to manually pick up: [GA events showing manually](https://i.stack.imgur.com/EVERi.png)”
Log in to reply.