title: Google Analytics on Subdomain
body: <p>I just generated the tracking code for a new Google Analytics account, and the domain I want to track is actually a subdomain. When setting up the account, I entered the subdomain as the URL I wanted to track, but I noticed when the tracking code was generated, it referenced the main domain and not the subdomain I had entered. Please see below, and please note that in the code below, I replaced the actual domain with "example.com". So, I have two questions related to this </p>
  
  <ol>
  <li><p>I plan to insert this tracking code on my subdomain, but do I need to do anything special in the analytics settings to ensure that I only see stats for my subdomain and not the main domain? I don't have control over the main domain, and they don't have analytics installed on it.</p></li>
  <li><p>If the person in charge of the main domain decides to install analytics on the main site, will my code affect his account in any way being that my tracking code references the main domain instead of my subdomain?</p></li>
  </ol>
  
  
  
  <pre><code>&lt;script&gt;
  (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','ga');
  
  ga('create', 'UA-46251874-1', 'example.com');
  ga('send', 'pageview');
  &lt;/script&gt;
  </code></pre>