Problem integrating Google Analytics

Recommended Posts


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:


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 + "]");
	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?



Share this post

Link to post
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?

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.