title: How do I configure my google analytics account to accept requests from file:// urls?
body: <p>I'm trying to get google analytics working with my PhoneGap/Cordova app. </p>
  
  <p>By default, the analytics.js lib will not send requests from file:// type urls. I found from <a href="https://github.com/h5bp/html5-boilerplate/issues/1444" rel="nofollow noreferrer">this site</a>, and the <a href="https://stackoverflow.com/questions/4502128/convert-google-analytics-cookies-to-local-session-storage/19207035?noredirect=1#19207035">StackOverflow question</a> that it points to, that I can get the analytics lib to use local storage, rather than cookies, for keeping track of the client ID by configuring GA thusly:</p>
  
  <pre><code>(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','http://www.google-analytics.com/analytics.js','ga');
  
  ga('create', 'UA-XXXXX-1', 'auto', {
          'allowLinker': true,
          'storage': 'none','clientId':localStorage.getItem('gaClientId')
      });
  ga(function(t){localStorage.setItem('gaClientId',t.get('clientId'));});
  </code></pre>
  
  <p>And then I can get the library to send requests from non-http/https urls by adding the following:</p>
  
  <pre><code>ga('set', 'checkProtocolTask', null);
  </code></pre>
  
  <p>Now I can see, from my browser console, that the library is sending page views out to google-analytics.com similar to the following:</p>
  
  <pre><code>http://www.google-analytics.com/collect?v=1&amp;_v=j31&amp;a=6458293880&amp;t=pageview&amp;_s=1&amp;dl=file%3A%2F%2F%2Fpath%2Fto%2Findex.html&amp;ul=en-us&amp;de=ISO-8859-1&amp;sd=24-bit&amp;sr=1440x900&amp;vp=1283x150&amp;je=1&amp;fl=16.0%20r0&amp;_u=cGAAAAQB~&amp;cid=389492833.14589283847&amp;tid=UA-XXXXX-1&amp;z=1277371227
  </code></pre>
  
  <p>However, on the google-analytics.com side, Google is ignoring that request once it receives it, and nothing shows up under my account.  If I manually change the "dl=file..." part of the above URL to "dl=http...", then Google accepts it, and I immediately see the request under the "Real-Time" tab of my account.</p>
  
  <p>So, it appears I've got the browser side of things set up correctly, but...</p>
  
  <ol>
  <li><strong>how can I configure my google-analytics account to accept the requests the browser sends?</strong>  </li>
  <li><strong>Alternatively, is there a way to configure the browser side of things so that it sends "dl=http://..." rather than "dl=file://...", even though it's coming from a file:// URL?</strong></li>
  </ol>
  
  <p>(I think I might prefer an answer to #2 over #1, if I had to choose one answer.)</p>
  
  <p>I know that there is a <a href="https://github.com/danwilson/google-analytics-plugin" rel="nofollow noreferrer">cordova plugin for google analytics</a>, but I haven't had much luck getting that one to work, and, even if I got it to work, I need my app to be able to log to multiple google-analytics accounts at once, which I don't think the plugin to can do.</p>