AdMob / AdWords Conversion Tracking in an Ionic App


A client for whom we’ve developed a hybrid app using Ionic had asked us to close the loop on their AdWords and AdMob marketing campaigns and turn on the ability to track conversions within the app.

Like always, we began with search on Google for an open-source Cordova plugin. There wasn’t much out there on the interwebs but we did find one Phonegap plugin called GoogleAppTracking Plugin

To get it working with Ionic, you can follow the instructions that are provided in the plugin’s GitHub README file but here are few pointers that threw us off a bit:

While running “ionic build android” we got an error that required for the following:
Ensure that the root config.xml has the following added to the tag:

xmlns:gap="http://phonegap.com/ns/1.0"

We weren’t sure where to add the tags:
Ensure that the following tag is added as a child of the tag.

<gap:plugin name="cordova-plugin-googleplus" source="npm">
  <param name="REVERSED_CLIENT_ID" value="{from Google Developer Console}" />
</gap:plugin>

Was there a JS file in include in index.html?
No

Does the object GappTrack need to be injected?
No.

Can the object GappTrack be called in anywhere (
We don’t think so. The plugin is not available via ngCordova and also is only initiated onDeviceReady(). So here is what we put within our onDeviceReady() tag:

if (window.cordova) {
    GappTrack.track("{tracking ID}", "{tracking key}", "0.00", false);
} else {
    console.log("WARNING: No GappTrack plugin found");
}

Hopefully people who want to use this plugin but are struggling setting it up can find this post and use our learnings to get going.

Share your Insights