Page 1 of 1

How to automate JavaScript analytics

Posted: Thu May 10, 2007 11:55 pm
by Anastasis
Our current website uses static HTML pages and we record stats using an analytics tool called WebCEO.

This records the page name (e.g. "consultancy.php" for a visited page by using some embedded JavaScript on each page.

The JavaScript looks like this:

Code: Select all

<!--WEBSITECEO:BEGIN:{764EEF2E-BC99-45CF-8627-300CE1BA2219}-->
<!--
Do NOT modify this script to avoid traffic misrepresentation! 
Web CEO 4 0300/1
Code initially inserted into: "/consultancy.php".
-->
<__script__ type="text/javascript"><!--
// hitlens v1.2.7
function hitlens_embedded() {
var id = 9999999;
var pc = 0;
var PAGENAME = escape('/consultancy.php');
var CONTENTGROUP = escape('');
var TRANSACTION = escape('');
var TRANSACTION_ID = 0;
var ORDER = escape('');
return "id="+id+"&pc="+pc+"&p="+PAGENAME+"&gr="+CONTENTGROUP+"&tr="+TRANSACTION+"&trid="+TRANSACTION_ID+"&ord="+ORDER;
}
//--></__script>
<__script__ type="text/javascript" src="/webceo.js"></__script>
<!--WEBSITECEO:END:{764EEF2E-BC99-45CF-8627-300CE1BA2219}-->
My question is how can I implement this in CMSMS so that the PAGENAME variable can be dynamically assigned?

Can I use the page alias and if so how?

If not, how should I do this?

Thanks in advance.

Re: How to automate JavaScript analytics

Posted: Fri May 11, 2007 6:44 am
by tsw
you can use {get_template_vars} tag to see what variables are available and then choose for example {$page_name} or {$page_alias} in you javascript to do this dynamically.

hope this helps

Re: How to automate JavaScript analytics

Posted: Fri May 11, 2007 12:47 pm
by Anastasis
tsw wrote: you can use {get_template_vars} tag to see what variables are available and then choose for example {$page_name} or {$page_alias} in you javascript to do this dynamically.

hope this helps
OK, thanks. Yes, this works, but is still not quite right for what I need.

Whilst I can enter the page alias to be, for example, "consultancy.php" (which is the name of the current static page being recorded by our web stats software), this gets changed to "consultancy-php" by CMSMS. I guess the reason for this is because the page URL cannot end with a .php, e.g. http://www.mywebsite.co.uk/cmsmadesimpl ... ltancy.php, instead it has to be: http://www.mywebsite.co.uk/cmsmadesimpl ... ltancy-php

Is there a workaround for this? Or would I need to capture the page name for use in the web analytics specifically for each page by using the {capture} function in the template?

Thanks again...

Re: How to automate JavaScript analytics

Posted: Fri May 11, 2007 4:27 pm
by Pierre M.
Hello Anastasis,

why not use pretty friendly URLs like site.co.uk/consultancy.html ? (see optional settings of the install in the doc)
May be it will be more {$page_alias} compatible ?

Pierre M.

Re: How to automate JavaScript analytics

Posted: Fri May 11, 2007 10:43 pm
by Anastasis
Pierre M. wrote: Hello Anastasis,

why not use pretty friendly URLs like site.co.uk/consultancy.html ? (see optional settings of the install in the doc)
May be it will be more {$page_alias} compatible ?

Pierre M.
Pierre

Thank you for this. As I understand it, pretty friendly URLs are used for the page name that appears in the browser address bar. Would that then translate to the page name that can be applied into the JavaScript for our web analytics? I guess JavaScript could be used to return the current page name and if that matched what appeared in the address bar (which it should) then that would work.

However, from what I can see of the built-in pretty URLs and the method using mod_rewrite, both of these return a page name that is based on a hierachical URL path, e.g. mysite.co.uk/parent/child.php. The problem is that with our current static site we have been using a flat site structure so that all pages are located in the root, e.g. mysite.co.uk/parent.php and mysite.co.uk/child.php

So, I don't think this will work in that if we were to use this method of a hierachical page URL that would hit our search engine position which has been built up over the last 2 years. Howver, I may have misunderstood or is there a workaround with either of these methods to produce the desired effect?

Thanks again...

Re: How to automate JavaScript analytics

Posted: Sat May 12, 2007 8:16 am
by tsw
if your page alias is "consultancy" and you want to send consultancy.php to analytics script just do a string concat.

var PAGENAME = escape('/{$page_alias}.php');

this gives you the option to change pretty urls like you wish (with .html or .aspx or maybe even / which I prefer myself)

but I dont quite get why you cant use page_alias directly? I think that the analyzer should understand anything in PAGENAME attribute.

Re: How to automate JavaScript analytics

Posted: Sat May 12, 2007 5:13 pm
by Pierre M.
Hello Anastasis,

if you have a flat URL scheme, you can keep it with CMSms. I think the idea behind page aliases is a direct access bypassing the hierarchy. This should do it your way.
Have fun !

Pierre M.

Re: How to automate JavaScript analytics

Posted: Sat May 12, 2007 10:05 pm
by Anastasis
TSW & Pierre

Many thanks for your replies. And thank you for answering my question so simply in that I missed what should be the obvious solution to this. I think it has been a case of getting so close to my question that I couldn't see beyond the end of my nose!

Thank you for your patience and help. :)