mbe's Forum Posts

  • jonathangoetz I'm afraid we only target mobile browser and in app webview users so I've no experience with any of the non web formats.

    I believe Google Analytics can be made to work with PhoneGap though so it's probably worth trying.

    I know Google Analytics doesn't like working in a local file that isn't served from a server, but the same is also true of Construct 2 games and obviously they work in CocoonJS!

  • Hi Guys,

    As we use Construct 2 predominantly to make 'gamified' mobile ads for our clients, getting user engagement statistics is vitally important for us so we tend to put Google Analytics on most of the things we do.

    When I started using Construct 2, it quickly became apparent that just pasting the GA tracking code into the index.html file didn't work, so previously I had been using the callJS plugin (thanks Joe7!) to import an external JS file containing the tracking code. For reasons that elude me this only worked with the old ga.js analytics code, but it did allow me to fire off events when users started the game, got killed, clicked the more info button, etc.

    Last week Google finally took their new Universal Analytics system out of beta and are now not issuing the old tracking codes. As we have a campaign featuring a Construct 2 game that is about to go live, I was forced to find a new solution that works with the new code. I thought I would share my finding here partly to help anyone else who is having similar problems, but also to see if anyone else has a better solution.

    From my basic understanding of JavaScript, it appear that there is some sort of namespace pollution which is causing the issue, so I got around the problem but putting the tracking code inside a module and renaming the Google Analytics function. Putting this script in the index.html header did the job:

    <script>
    
    var scirraAnalytics = (function(){
    
    	(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    	(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    	m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    	})(window,document,'script','//www.google-analytics.com/analytics.js','__gaTracker');
    
    	__gaTracker('create', 'UA-********-**', 'example.com');
    	__gaTracker('send', 'pageview');
    
    	function externalLink(url){
    		try{
    			__gaTracker('send', 'event', 'External Link', url);
    		}catch(err){}
    		setTimeout(function(){
    			window.location = url;
    		},300);
    	}
    
    	function fireEvent(category, action) {
    		try{
    			__gaTracker('send', 'event', category, action);
    			console.log(category + " - " + action);
    		}catch(err){}
    	}
    
    	return {
    		externalLink: externalLink,
    		fireEvent: fireEvent
    	}
    
    })();
    </script>
    [/code:11dycmzk]
    (You will of course need to update the UA-********-** tracking code and URL)
    
    With this script I can now fire events off from within the game using the Execute JavaScript option in the Browser plugin , e.g,:
    
    [code:11dycmzk]"scirraAnalytics.fireEvent('Level " & Level & " Completed', 'Score: " & Score & "')"[/code:11dycmzk]
    
    By firing this at the end of each level we can see how far our users are progressing through the game and how much they've scored.
    
    I also put in an external link function in to record when our users click on an in game link to an external site. For anyone wondering you need to add a delay in to give Google time to record the event, hence the 300 milliseconds. It is used like this:
    
    [code:11dycmzk]"scirraAnalytics.externalLink('https://www.scirra.com/')"[/code:11dycmzk]
    
    In both function calls note the usage of both single and double quotation marks!
    
    Anyway I hope this helps anyone else who is having problems tracking how their games are being used and if anyone else has a better solution, please share it!
  • Thanks Ashley, much appreciated!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks Ashley, I'll carry on using r154 until the next beta.

    I didn't find the issue until after r158 had been released, our client actually pointed it out to us which was a little bit embarrassing!

  • Hi Guys,

    I appear to have found a problem with iOS7 Safari on iPhones when turning the screen from landscape to portrait.

    Link to .capx file (required!):

    cdn.mobileembrace.com/uploads/mobileembrace.com/test/r156_iOS7_portrait_landscape_issue.capx

    (This file is the most basic case, window size and layout set to 640, 744 with one sprite filling the screen. Fullscreen in browser set to Letterbox scale.)

    Steps to reproduce:

    1. Load game on iOS7 iPhone (4S and 5 tested)with phone portrait

    2. Turn phone to landscape orientation

    3. Turn phone back to portrait orientation

    Observed result:

    After turning the phone back to portrait, the game reappears half off the screen.

    Expected result:

    Game not to be half off the screen!

    Browsers affected:

    Chrome: n/a

    Firefox: n/a

    Internet Explorer: n/a

    iOS7 Safari: Yes

    Android Stock Browser: No

    Chrome for Android: No

    Firefox for Android: No

    Operating system & service pack:

    Windows 7 Professional Service Pack 1

    Construct 2 version:

    First found the problem with r156, I then saw the new stable release r158 was available so I upgraded to that version but I get exactly the same problem.

    I then downgraded to r154 which I knew worked with some older projects I'd worked on and it work as expected.

    The problem seems to have been introduced between r154 and r156, I didn't try r155 so I don't know if that one is affected.

    Thanks!

  • It's difficult to see how this can be fixed, even if you can add some user interaction such as swiping up to hide the address and bottom tool bar, as soon as anyone touches the bottom of the screen they'll pop right back again.

    This is also a problem for mobile sites with navigation or banner ads at the bottom of the screen. It looks like we'll have to design everything to fit in a 640 x 744 (320 x 372) area to accommodate iPhone 4S with iOS 7 users now.

    I saw some people on other forums saying Apple it trying to force people to make Apps for the App Store. Initially I thought that sounded like a crazy conspiracy theory, but the more I think about it the more I think it might be true.

    (* I just had to quickly redesign several layouts for a "gamified" mobile advertising campaign, so I'm feeling pretty sore about the whole iOS 7 thing!)

  • Thanks Ashley!

    If I get a work around up and running before then I'll try and post it here.

  • Link to .capx file (required!):

    cdn.mobileembrace.com/uploads/mobileembrace.com/test/SwipeTest.capx

    Steps to reproduce:

    Hi Guys (long time reader, first time poster),

    I appear to have discovered a problem with "On Any Touch End" on the stock Android browser on the Samsung Galaxy S3 and original Samsung Galaxy Note.

    Basically I want to build a game for phones with Temple Run style controls, i.e. you swipe the screen left or right to move.

    I after reading the forums, I put together a simple file that records the touch position on any touch start and any touch end and compares the X values to work out if the user has swiped left or right.

    This seems to work fine on most of the browsers and devices I've tested it on, but not on the Samsung Galaxy S3 or Note.

    I added an additional text box to display the Touch.X values that were recorded, and it appears that something is going wrong with the "On Any Touch End" value as it always reverts to it's original value, 0 in this case.

    Interestingly if you touch the screen with 2 or more fingers the end touch of any additional touches seems to register, but as soon as you remove your last finger the end touch goes back to 0.

    I've tested this on a range of devices and it works fine on all the desktop browsers I've tried and the following devices:

    iPhone 4S

    Samsung Galaxy Nexus stock browser

    Samsung Galaxy S4 stock browser

    HTC Desire

    It also works on the Chrome mobile browser on the affected devices (the GS3 and Note), but unfortunately most people use the stock browser and the Galaxy S3 is second only to iPhones in our target audience.

    If anyone can suggest any workarounds, I would be very grateful!

    Observed result:

    "On Any Touch End" not working on Samsung GS3 & Note

    Expected result:

    "On Any Touch End" to work on Samsung GS3 & Note!

    Browsers affected:

    Chrome: no

    Firefox: no

    Internet Explorer: no

    Operating system & service pack:

    Windows 7 Professional Service Pack 1

    Construct 2 version:

    Construct 2 Release 139 (64-bit)

    Thank you!