1.2. How to install Google Analytic code for core PHP site?

Here are the instructions for implementing Google Analytic on website in core PHP.

1. Copy the code:

In Google Analytic or other tracking program find the code, copy and then paste it into every page of your website that you want to track immediately before the closing </head>tag.

Here is just an Example. Please adjust to your case

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25866384-1']);
  _gaq.push(['_setDomainName', 'mondosol.com']);
  _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>



2. Install the code:

In the index or main page of your website you need to install the tracking code with ftp program (like Filezilla) or directly in your Hosting website with the account information received by email.*

Here is just an Example. Please adjust to your case
  • Go to Domain > mondosol.com > html > Search for index.php
  • Insert:Google Analytics tracking code
  • What are you tracking? One domain with multiple sub domain. 
  • Domain name: www.mondosol.com

To install the JavaScript, copy your tracking code--either the code provided during setup, or your customized snippet--and paste it into your page.

One of the main advantages of the asynchronous snippet is that you can position it at the top of the HTML document. This increases the likelihood that the tracking beacon will be sent before the user leaves the page. It is customary to place JavaScript code in the <head> section, and we recommend placing the snippet at the bottom of the <head> section for best performance.



3. Verify the installed code:

You can also view your webpage’s source code to verify that the tracking code is installed.  

Navigate your browser to any page on your site.  Right click within the browser window and select the “View Page Source” or “View Source” option in your browser. 

This will open a new window that contains the source code for that page.

Now search for ga.js. (From the source code menu, select “Edit” and click the “Find” option.)

If you find the Google Analytics tracking code on your page, then it is likely that Google Analytics has been successfully installed on your site.  

Repeat this process across several pages on your site to make sure that your installation is complete.



Comments