2

we are using Google Analytics script on all pages below:

<script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-XXXXXX-1");
    pageTracker._setDomainName(".mydomain.com");
    pageTracker._trackPageview();    
</script>

I need to change a the last line in the script to pageTracker._trackPageview("Success"); at run time. The Google Analytics injects this script at some point in the page building process. It's a bit tricky because once the Google Analytics module is added, it runs for all pages requested and puts this scrip at the end of the body tag.

Is there a way to examine the HTML, parse it, find that line and edit it? What's the best way to accomplish that?

Thank you.

1 Answer 1

2

SiteAnalytics.config, located in the DNN root, allows you to globally modify the analytics script and have some control over where it is injected.

I have used it to load the new asychronous analytics script to <body> instead of <head>, in order to avoid the the problem in the default configuration, where title element is positioned after the script, and "Content by Title" reports won't work.

See Also

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.