Jump to content

Problem integrating Google Analytics


koobazaur
 Share

Recommended Posts

Hola,

So I tried integrating GA into my latest game for some stats tracking based on official google docs. I got the page views and events working but my metrics show up as "not set" for some reason. Here's my set up:

e4A4zIX.jpg

Here's the code I set up:

 

	TrackPageView: function(inPage, inTitle)
	{
		if(!this._IsInitted || !this._IsEnabled) { return; }

		ga('send', 'pageview', inPage);

		if(typeof inTitle !== 'undefined')
		{
			ga('set', 'title', inTitle);
		}

		console.log("GA PageView: [" + inPage + "][" + inTitle + "]");
		
	},
	TrackEvent: function(inCategory, inAction, inLabel)
	{
		if(!this._IsInitted || !this._IsEnabled) { return; }

		ga('send', 'event', inCategory, inAction, inLabel);		

		console.log("GA Event: [" + inCategory + "][" + inAction + "][" + inLabel + "]");
	},
	//https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets
	TrackEventVar(inIndex, inValue)
	{
		if(!this._IsInitted || !this._IsEnabled) { return; }

		var i = 'metric' + inIndex;
		//ga('send', 'event', inCategory, inAction, {
		//  i: inValue
		//});
		ga('set', i, inValue );

		console.log("GA EventVar: [" + i + " = " + inValue + "]");		
	},

 

And here's where I use it:

 

					sGA.TrackEventVar(1,  Math.floor(playTime));
					sGA.TrackEventVar(2,  Math.floor(sStats.FollowerSpawnedTotal));
					sGA.TrackEventVar(7,  Math.floor(sStats.BlueFlowersCollected));
					sGA.TrackEventVar(4,  Math.floor(sStats.FollowersDied));
					sGA.TrackEventVar(3,  Math.floor(sStats.FlowersCollected));
					sGA.TrackEventVar(5,  Math.floor(sStats.BunniesKilled));
					sGA.TrackEventVar(6,  Math.floor(sStats.SnakesKilled));
					sGA.TrackEvent("Game End", "GameEnd", "Game WON");
					sGA.TrackPageView("/gather-game-end-win", "GATHER Game WON");

Both Event and PageViews report properly, and the metrics under "Audience -> Custom -> User Defined" show up as "(not set)" 

Any idea?

 

 

Link to comment
Share on other sites

I have not worked with custom events, I'm curious if you've tracked activity in your network tab of a browser to see if data is being sent to google for your "sGA.TrackEventVar()" calls. Maybe they are responding with data or messages that could be helpful?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...