Posts Tagged Windows 8

Windows Store Apps: Adding Google Analytics to Windows 8 Store Apps

So you’ve built your very first Windows 8 Store app, had it approved and it is now available in the Windows App Store. The only thing is, you will have to be patient to see if people are downloading and using your app. Since the Store dashboard only updates your apps download stats once a day, it can be a highly frustrating wait. But the reality is that you don’t need to wait. By implementing Google Analytics within your app, you can see instantly how many people are using your app, track their interaction and find out where they are using your app from.

Using Google Analytics in your Windows Store app is quite straight forward. There are a number of free libraries that allow you to do this in minutes. I tried out a few of such libraries and settled on one – for me, the best was Google Analytics SDK for Windows 8 and Windows Phone.

Here’s how you can implement this within your Windows 8 or Phone XAML project (for JavaScript solution, for this guide).

1. Create your Google Analytics Account

ga_setup.png

2. Make sure you select “App” and not “Website”

3. In your app manifest, add the “Internet” capability under the “Capabilities” tab.

4. Install the Google Analytics SDK via Nuget

nuget1.png

nuget2.png

5. Modify the analytics.xml file that is automatically added to your project after installing the SDK.

6. You should change the tracking-id, the appName and appVersion values.
Obviously the tracking-id should be that of the account created in Google Analytics.

<?xml version=”1.0″ encoding=”utf-8″ ?>
<analytics xmlns=”http://googleanalyticssdk.codeplex.com/ns/easytracker”>
<!–Replace placeholder ID with your tracking ID–>
<trackingId>UA-XXXX-Y</trackingId>
<!–Replace placeholder name with your app name–>
<appName>TestApp</appName>
<!–Replace placeholder version with your app version–>
<appVersion>1.0.0.0</appVersion>
</analytics>

7. Add the tracking code to your porject…

// track the page view
GoogleAnalytics.EasyTracker.GetTracker().SendView(“main”);

// track a custom event
GoogleAnalytics.EasyTracker.GetTracker().SendEvent(“test”, “userclick”, null, 0);

Once you build and test your app, you should instantly see statistics being tracked in the “Real-Time” section of your Google Analytics.

Happy tracking!

 

Tags: , , , , ,

No Comments

Windows Store Apps: Add a Privacy Policy link to Settings Charm (C# & JavaScript)

In my (little) spare time recently, I’ve been playing around with developing Windows 8 Store apps. I submitted my very first app to the Store this week and unfortunately the app failed the certification process.

The reason for failure was simple… I requested Internet Connection permissions in the app and therefore, based on the Windows Store App certification requirements, I should have included a Privacy Policy link within the app. In fact, I needed to include the Privacy Policy link from the Settings Charm.

Of course, having never done this before I had no idea how to do this. After much searching, I finally figured out how to do this.

So if your app has failed in your quest to be certified, here’s the simple steps required to get a Privacy Policy link included in the Settings Charm for your Windows Store app….

C# Solution

1. Add the following name spaces
using Windows.UI.ApplicationSettings;
using Windows.UI.Popups;

2. Add the event handler to your app initialisation
SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested;

3. Then add the following methods…
public SettingCharmManager()
{

SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested;
}
private void SettingCharmManager_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
args.Request.ApplicationCommands.Add(new SettingsCommand(“privacypolicy”, “Privacy Policy”, PrivacyPolicyLink));
}

private async void PrivacyPolicyLink(IUICommand command)
{
Uri uri = new Uri(“<enter the full URL to your Privacy Policy here>”);
await Launcher.LaunchUriAsync(uri);
}

JavaScript Solution

var settingsPane = Windows.UI.ApplicationSettings.SettingsPane.getForCurrentView();
function commandsRequested(eventArgs) {
    var applicationCommands = eventArgs.request.applicationCommands;
    var privacyCommand = new Windows.UI.ApplicationSettings.SettingsCommand('privacy', 'Privacy Policy', function() {
        window.open('<enter your Privacy Policy URL here');
    });
    applicationCommands.append(privacyCommand);
}
settingsPane.addEventListener("commandsrequested", commandsRequested);

 

Assuming your Privacy Policy link is valid, you should not fail for this reason on your next app submission! :)

Enhanced by Zemanta

Tags: , , , , , , , , ,

No Comments