chungster

Q: Google Analytics and iWeb

I'm attempting to insert an html tag generated by Google Analytics into our website that is published using iWeb (the latest version, sorry, I'm no longer on site).  Can anyone help me?

 

Thank you,

Jeff

iMac, Mac OS X (10.6.8)

Posted on Jan 6, 2015 6:42 PM

Close

Q: Google Analytics and iWeb

  • All replies
  • Helpful answers

  • by Ethmoid,

    Ethmoid Ethmoid Jan 7, 2015 1:02 AM in response to chungster
    Level 6 (11,282 points)
    Jan 7, 2015 1:02 AM in response to chungster

    You would need to insert this manually into your html page - so you need to open your html page with a TextEditor such as TextWrangler and add the code in.

     

    The other way that you can add SEO and Google Analytics to an iWeb site is to get iWeb SEO by Rage Software - it used to be free, but I'm not sure if it is now.  You would then need to publish your site to your desktop from iWeb and then open your site with the iWeb SEO tool and add your tags and page names and analytics code through there and then re-publish your site.

     

    If it is only one lot of code, then it might be easier just to use a text editor and add it to your html page and then re-upload it.

  • by Wyodor,

    Wyodor Wyodor Jan 7, 2015 8:19 AM in response to chungster
    Level 6 (19,753 points)
    Jan 7, 2015 8:19 AM in response to chungster

    Here's how :

     

    Copy your Analytics code without the <script type="text/javascript"> and </script> lines.

     

    Paste it in a plaintext file and save it as analytics.js.

     

    Put the file in a folder in the root of your webserver. I use folder js.

     

    Paste this code in a HTML Snippet :

     

    <script>

    var headid = parent.document.getElementsByTagName("head")[0];

    var newScript = parent.document.createElement('script');

    newScript.type = 'text/javascript';

    newScript.src = '/js/analytics.js';

    headID.appendChild(newScript);

    </script>

     

    Publish your page and open it in a browser window.

     

    When you go to the Google Analytics page, you can see it in real time.

  • by chungster,

    chungster chungster Jan 8, 2015 3:26 PM in response to Ethmoid
    Level 1 (0 points)
    Jan 8, 2015 3:26 PM in response to Ethmoid

    Thanks for the info!  It's way over my head, s I don't know how to manipulate the website outside of iWeb.  But I did download TextWranger and notice it has some save as or connect to server options. 

     

    Can I just open the lab's website in a browser and do "view source" in the developer menu (in Chrome) and copy and paste that html code, then add the tracking tag code then somehow get that html file back into iWeb?  iWeb help files give no help on this matter, however.

  • by chungster,Helpful

    chungster chungster Jan 8, 2015 3:43 PM in response to Wyodor
    Level 1 (0 points)
    Jan 8, 2015 3:43 PM in response to Wyodor

    Hi Wyodor,

     

    Thanks for your procedure.  Here's what I did to try to follow it:

    The tracking code issued by Google Analytics is:

     

    <script>

      (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-58307704-1', 'auto');

      ga('send', 'pageview');

     

     

    </script>

     

    So I copied everything from-- (function. . .   to 'page view'); --omitting the <script> above and </script> below.  Pasted into TextWrangler and named it analytics.js (couldn't use TextEdit because it only permits RTF, not plaintext as you specified.  Since TextWrangler give me no options for saving formats, I am presuming it is plain text?

     

    But I'm stuck here, as I do not know how to put the file within the js folder in the root directory of the web server, at least via iWeb. 

     

    I get the feeling that iWeb is incredibly too simple. . . that the procedures your referring would involve other coding programs (or whatever, my ignorance on these things is apparent).  But this is how iWeb is pushing it to the university server.  Screen Shot 2015-01-08 at 1.31.59 PM.png

     

    If i'm heading in the right direction, please let me know. . .

    Also any thoughts on how to best abandon iWeb and move over to something that the rest of the world uses, like WordPress?

     

    All of this was setup before I joined the lab, and I'm sure iWeb was ok for the purposes at the time.  I just get the feeling it's not very good, and since Apple has abandoned it, I see no reason to stick with it.

     

    Much Mahalo's for your help!

  • by Wyodor,Helpful

    Wyodor Wyodor Jan 8, 2015 4:26 PM in response to chungster
    Level 6 (19,753 points)
    Jan 8, 2015 4:26 PM in response to chungster

    If it's the university server, then the IT dept can provide you with the details how to connect to the server.

     

    Here it is :

     

    http://www.hawaii.edu/askus/694

     

    You usually use a FTP application, like :

     

    https://cyberduck.io/

     

    And yes, you can use TextWrangler to connect to the server and save the .js file there.


    (You may have to tell the IT guys to update their page. We're currently 10 years later.)

     

    TextEdit can create plaintext files.

     

    It's in the preferences and in one of the menus.

     

    The instruction how to add code to iWeb is clearly written in my previous post.

  • by Wyodor,

    Wyodor Wyodor Jan 8, 2015 4:39 PM in response to Wyodor
    Level 6 (19,753 points)
    Jan 8, 2015 4:39 PM in response to Wyodor

    Since this is your website, the path to the analytics.js file is not correct :

     

    http://www2.hawaii.edu/~kpauker/Pauker_Lab/People.html

     

    The line in the code where it says :

     

    newScript.src = '/js/analytics.js';


    should be in order of preference :


    newScript.src = '../../../js/analytics.js';


    Or :


    newScript.src = '/~kpauker/js/analytics.js';

     

    Or :

     

    newScript.src = 'http://www2.hawaii.edu/~kpauker/js/analytics.js';

  • by Wyodor,

    Wyodor Wyodor Jan 8, 2015 5:45 PM in response to Wyodor
    Level 6 (19,753 points)
    Jan 8, 2015 5:45 PM in response to Wyodor

    Small correction. The line should read :


    newScript.src = '../js/analytics.js';


    There were too many dots.

  • by Ethmoid,

    Ethmoid Ethmoid Jan 9, 2015 12:49 AM in response to chungster
    Level 6 (11,282 points)
    Jan 9, 2015 12:49 AM in response to chungster

    Yes, it would be easy to install WordPress on the server.

     

    You would need to go to WordPress.org and then download the latest version of WordPress and load it onto the server and then install it and away you go.  The only install that you would need to do is at the beginning and then everything can be done online without the need to upload any further files to your server and then to alter things, all you need to do is log into the website online and that is it.  Could save you a lot of time.

     

    WordPress is one of the Content Management Systems (CMS's), so if you are considering using that, then also take a look at the others, such as Drupal and Joomla so see whether these would suit you best, but from what I can see of your site, WordPress might suffice very well indeed.

     

    Go and take a look at WordPress.org.

  • by chungster,

    chungster chungster Jan 10, 2015 12:50 AM in response to Ethmoid
    Level 1 (0 points)
    Jan 10, 2015 12:50 AM in response to Ethmoid

    Thank you very much Ethmoid!  I appreciate the support from the kindness of strangers. 

  • by chungster,

    chungster chungster Jan 10, 2015 12:55 AM in response to Wyodor
    Level 1 (0 points)
    Jan 10, 2015 12:55 AM in response to Wyodor

    Thank you Wyodor.  The step by step direction and specific instruction are most helpful.  I've decided to wait until I have some more support from the IT department before I start noodling in a realm I'm clearly under qualified to play in.

     

    Additionally, we're probably going to switch to WordPress, so my next mission will be to bone up on that.  Fortunately, I did come across the Google Analytics "certification" course on Google's site.  So at least I'm getting the bigger picture!

     

    Rock on. . .