Automatic creation of websites in piwik?

Thinking out loud and asking questions as I go.

When I “Add a new website” what are the URLs used for? For example. If I entered foo.com and then installed the tracking code on bar.com would it show in the report?

If not is there a way to make this happen? I have 100s of domains and I was thinking it would be nice to treat them all as 1 site for reporting purposes. I would then include the domain name in the document title.

piwikTracker.setDocumentTitle(hostname + doc name)

This would give me an easy way to track my most popular sites… I think.

Also, is there a way to create new sites outside of the application? for example, if I called Piwik.getTracker with an ID that was unknown would it be created automatically? I suspect not as this might have unintended consequences.

What I need is an automated way to add new sites and to know what the identifier of that site will be. If a name could be specified for the identifier that would keep me from needed a lookup table.

ex:
Piwik.getTracker(pkBaseURL + “piwik.php”, ‘foo.com’);

Is any of this possible today or planned (assuming it fits within the design)?

Thanks
Tony

Yes, yes, no (but interesting idea), and yes.

I would suggest going with the API. Refer to the SitesManager API to add sites programmatically.

Then check out the Multi-site summary plugin (which we are planning to add to Piwik as a core plugin). http://dev.piwik.org/trac/ticket/389

Thanks for the response (i was starting to read the code but it was slow going).

How are the URLs entered in “Add a new website” used? If I have foo.com listed as the only website and I install the tracking code on foo.com and bar.com what is the difference between the reporting of traffic on these 2 sites?

If you use a single site ID, you’re going to aggregate your data with no way to segment by site.

So the API doesn’t give examples for the update or add methods. Do these need to be done via HTTP PUT and POST? I tried via GET

mysite/?module=API&method=SiteManager.updateSite&idSite=1&siteName=testing&token_auth=mytoken

and it returned
“The plugin ‘SiteManager’ is not activated. You can activate the plugin on the ‘Plugins admin’ page.”

The plugin shows as active so I’m guessing this is just a bad error message.

Should I be doing a HTTP PUT?

You’re going to think, DOH!

It’s SitesManager, not SiteManager.

[quote=vipsoft @ Nov 5 2009, 05:26 PM]You’re going to think, DOH!

It’s SitesManager, not SiteManager.[/quote]

I love it when the answer is right under your nose. Thanks for pointing out my typo.

Seems GET or POST works fine. Watch out for the REST purist… when I was at AOL we built an API that we called REST but it didn’t conform to the strict HEAD/GET/PUT/POST methodology and we got flamed. They don’t mention REST on their HTTP APIs anymore unless they are strictly REST (which is not possible if you’re supporting AJAX and such). :wink: