Mobile app version of vmapp.org
Login or Join
Shelton105

: Keep Google Analytics in a backup site or not? I backed up my website and uploaded it to another server for testing and backup purposes. Should I remove or edit the Google Analytics snippet

@Shelton105

Posted in: #Analytics #Google

I backed up my website and uploaded it to another server for testing and backup purposes.

Should I remove or edit the Google Analytics snippet from the index.php (which is for the real site), or does it not matter as it's not the same server and url address as the one declared at Google Analytics account?

The reason I don't want to remove it is in case someone forgets about it if they upload the backup to the real site in case the real one breaks. Also I know that if I turn off the website there is no GA snippet, but I need it open so I can easily access and test it so I don't have to write pass all the time.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Shelton105

2 Comments

Sorted by latest first Latest Oldest Best

 

@Holmes151

As Gabriel said. I found this explanation from GA:
Hostname
This is the hostname or domain that visitors used to reach your site. Typically this is your site's domain. For example, if you host your blog on mysite.example.com, then your hostname report will contain mysite.example.com. In some cases, your website might be hosted on other domains, such as when you create a mirror (copy) of your site to host on a domain in another country (e.g. mysite.example.uk). In addition, if someone copies a page from your website directly without modifying any of the source code (including the tracking code) and places that page on their own website, your reports will reflect traffic to that page from that hostname as well. You can use profile filters to ensure that traffic only from allowed hosts reaches your reports.

Another Solution is to add a PhP Code:

<?php
// gets the actual environment root URL
$url = JURI::root();

// see if is in production environment and, if so, echoes the analytics' script tag
if (strpos($url, "www.productionenvironment.com") !== false) {
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-Y']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

<?php
}
?>


Personally I prefer Gabriel's solution as it saves additional code from the website.

10% popularity Vote Up Vote Down


 

@Courtney195

Go to Audience > Technology > Network > Primary Dimension: Hostname

Look for any other hostnames not associated with your production account. Take note.

Now go to Admin > Profiles and select your site profile. Select Filters tab and Add Filter. Create a new filter with criteria "Exclude" - "Traffic to the hostname" - "that are equal to" and type the dev server hostname in the field. Save and you should be all set keeping the GA code on the other test site without any troubles.

You could also add a quick check on the server to determine the URL and display the GA code only on the production server - best of both worlds.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme