I do not understand why this works;
ga('send', 'pageview');
setTimeout("ga('send','event','Engagement','SessionPing','30s')", 30000);
And this does not work
ga('send', 'pageview');
setTimeout("ga('send',{
hitType: 'event',
eventCategory: 'Engagement',
eventAction: 'SessionPing',
eventLabel: '30s'
})", 30000);
Can anyone explain why one would work and not the other? The second method seems to prevent GA from firing completely and I recorded no data for several days - the error message shown Google's Chrome Tag Assistant is that javascript file has not loaded.
I'd like to know because I want to get a better understanding of GA and javascript - this makes no sense to me, I can not see any syntax or format errors in the second method.