4

I have portal which behaves like multiple portal. The portal code base is same but for all sites but content is based on which url or domain you came across. Currently i am able to track my domain

example.com

and also subdomains like

a.example.com, b.example.com

. But i want to also track

anotherexample.com

which also point to same domain. How can I do? Any suggestions?

3
  • Have you read code.google.com/apis/analytics/docs/tracking/… ?
    – Eduardo
    Commented May 23, 2011 at 0:51
  • anotherexample.com respond the same thing? Ir is it just a redirection?
    – Eduardo
    Commented May 23, 2011 at 13:02
  • it is not a redirection. as i said our portal behave like multiple portals. if you type abc.com you see abc site. if you type def.com you see def.com. Content is different? Make it clear?
    – gandil
    Commented May 23, 2011 at 15:58

1 Answer 1

3

multiple url pointed to same code base. It does not matter. The only matter is the url above and the tracking code in site is matching or not. So you have to take google access code from database which just write in address bar.

Codes:

<!-- Google Analytics -->
<script type="text/javascript">
    var accountNameFromDB = ...Some Operations...
    var domainNameFromDB = ...Some Operations...
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', accountNameFromDB]);
    _gaq.push(['_setDomainName', domainNameFromDB]);
    _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>

Just take accountNameFromDB and domainNameFromDB variables dynmically. Add this code head of master page(or main template) or add every page.

2
  • I'm currently doing this, and it's completely incorrect and contrary to Google's documentation: developers.google.com/analytics/devguides/collection/gajs/…
    – Cerin
    Commented Oct 25, 2012 at 14:32
  • this is prepared with this guide cerin. the difference is domainname and domain name unique id come from database.
    – gandil
    Commented Oct 26, 2012 at 12:58

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.