Tracking multiple websites with the same base URL?

Hi there,

Installed Piwik 1.1.1, and got up and running fairly quick. I’ve searched and checked the FAQs for my question, but no joy.

I have a site where users can register and then get their own sub-URL (not subdomain). I wish to use the same installation for tracking all visitors on all URLs, as well as tracking users on just specific sub-URLs for displaying to the registered users.

URL layouts;

Piwik installed at: analytics.example.com
Domain: www.example.com
Domain-specific URLs; www.example.com/register, www.example.com/login, etc
User’s URL: www.example.com/user1, www.example.com/anotherUser, etc.

I’ve figured out that I can setup multiple “sites” in Piwik then use the CMS to selectively include javascript to only track sites when I want it to, so I’ve ended up with something like;


<!-- Piwik -->
<script type="text/javascript">
    var pkBaseURL = (("https:" == document.location.protocol) ? "https://analytics.example.com/" : "http://analytics.example.com/");
    document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
    </script><script type="text/javascript">
    try {
        var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
        piwikTracker.trackPageView();
        piwikTracker.enableLinkTracking();
    } catch( err ) {}
    try {
        var piwikTracker2 = Piwik.getTracker(pkBaseURL + "piwik.php", 2);
        piwikTracker2.trackPageView();
        piwikTracker2.enableLinkTracking();
    } catch( err ) {}
</script><noscript><p><img src="http://analytics.example.com/piwik.php?idsite=1" style="border:0" alt="" /><img src="http://analytics.example.com/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Tag -->

This would be for when someone is browsing www.example.com/user1 - I want to track all visitors (into Piwik’s site #1), as well as visitors to a specific user (into Piwik’s site #2).

Is this the best way to go about it?
Is there any issues that could come up due to doing this (such as the cookie set for piwikTracker2 overwritting that of piwikTracker, etc)?

Thanks for any and all assistance you can provide!

Jess.

Bump.

Anyone have any idea about this?

Looks ok to me. What problem are you encountering?

No problems, but I’m afraid of the ones I haven’t seen yet.

As I said in the original post;
“Is this the best way to go about it?
Is there any issues that could come up due to doing this (such as the cookie set for piwikTracker2 overwritting that of piwikTracker, etc)?”

Thanks for your help, vipsoft :slight_smile:

Hi, we have the same problem: track one page with multiple IDs.

In the PIWIK-Faq there was a post on this topic and we create the code below.

There is one problem: piwik only tracks the first ID not the second!

Has anybody a solution for this?


<!-- Piwik -->
<script type="text/javascript">

                var pkBaseURL = (("https:" == document.location.protocol) ? "http://www.example.de" : "http://www.example.de");
                document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script>

<script type="text/javascript">
                try {
                var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 4);
                piwikTracker.trackPageView();
                piwikTracker.enableLinkTracking();
                var piwik2 = Piwik.getTracker(pkBaseURL + "piwik.php", 3);
                piwik2.trackPageView();
                piwik2.enableLinkTracking();
                } catch( err ) {}
              
</script>

<noscript>
<p><img src="http://www.example.de/piwik.php?idsite=4" style="border:0" alt="" /></p>
<p><img src="http://www.example.des/piwik.php?idsite=3" style="border:0" alt="" /></p>
</noscript> 
<!-- End Piwik Tracking Tag -->

Hmm. We’ll investigate. Sounds like a regression.

screendiver: we aren’t able to reproduce the problem you’re seeing; if you’d like to PM your site’s URL, we can take a closer look

Hi Everyone,

i have around same kind of issue. i am generating the HTML website based on the content of the user and hosting in on my domain. like,

wwww.mydomain.com/user1/english/index.html
www.mydomain.com/user2/french/index.html

and so on…

i wanted to generate the user account in the piwik database and tracking script for each language by each user if user wants to publish his website. the same user can login and can view the statistics of all its created website only.

how i can fulfill this task, as i am new to piwik.

thank you so much for any help and tips.

301 Moved Permanently Was this solved, if yes, what cause?

If the bug is still here, please create a ticket in dev.piwik.org with the code to reproduce, thanks!