Maximus S
Maximus S

Reputation: 11095

Google Analytics for Chrome App

Situation:

I want to track events from my chrome app that has the following URL

chrome-extension://APP_ID.

In Google Analytics webpage, the only supported protocols are http and https

enter image description here

I just entered a random URL for the Website URL for now. I also set my manifest properly:

"permissions": ["webview", "browser", "http://www.youtube.com/*",
  "https://www.youtube.com/*", "https://fonts.googleapis.com/*",
  "https://www.google-analytics.com/*", "https://ssl.google-analytics.com/", "storage", "notifications
 ],
"sandbox": {
  "pages": ["sandbox/sandbox.html"]
},

Then, from my app I do the following when the app starts inside a sandbox:

(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','https://ssl.google-analytics.com/analytics.js','ga');

ga('create', 'UA-TRACKING-ID', 'auto');
ga('set', 'checkProtocolTask', null); // Removes failing 
ga('send', 'pageview');

Problem:

The analytics page doesn't show any events so I am assuming setting the default url properly might actually matter. What should I do to track events from my Chrome app?

Update:

I see that the following request fires.

http://www.google-analytics.com/collect?v=1&_v=j41&a=1768111489&t=pageview&_s=2&dl=chrome-extension%3A%2F%extension_ID%2Fsandbox%2Fsandbox.html&ul=ko&de=EUC-KR&sd=24-bit&sr=1440x900&vp=300x200&je=0&fl=21.0%20r0&_u=SAEAAEABI~&jid=&cid=2006929393.1458033861&tid=UA-75139981-5&z=437206753' -H 'Pragma: no-cache' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8,ko;q=0.6' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36' -H 'Accept: image/webp,image/,/*;q=0.8' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive

Does this mean I am sending Google Analytics requests correctly? Should I wait a couple of days to see the first update?

Upvotes: 1

Views: 477

Answers (1)

Xan
Xan

Reputation: 77482

Note that currently Apps documentation has a link to a special library, Chrome Platform Analytics, that takes care of most of the setup for you, bypassing the need for tricks like sandboxing.

However, for the most relevant part of your question - you're trying to create a wrong property type. Even though it's not intuitive, you need to set up a Mobile App property. There, you won't need to provide a URL. This is part of setting up the above library as well.

Oh, and because the URLs are still "special", sending a pageview does not work for it. Using the above library, sendAppView() is the way to go; otherwise, you can always send custom events.

Upvotes: 1

Related Questions