Search code examples
apimatomo

Piwik statitics about all websites


Is it possible to use the Piwik-API with all Websites, not just for a single one?

What i want to do is get a mean value of used browsers. I can do this for a single website like this:

?module=API&method=UserSettings.getBrowser&idSite=1&period=day&date=last10&format=rss

If i just remove idSite=1 i get an error.


Solution

  • You can specify all sites using idSite=all, you can also specify multiple sites by separating the ids with commas idSite=1,2,4,5.

    The resulting output is given per idSite wrapped in an extra <results> tag, so whereas before you had

    <result>
        <row>
            <label>Chrome 14.0</label>
            <nb_uniq_visitors>13</nb_uniq_visitors>
            ...
        </row>
        <row>
            <label>Chrome 13.0</label>
            <nb_uniq_visitors>13</nb_uniq_visitors>
            ...
        </row>
        ...
    </result>
    

    You now get

    <results>
        <result idSite="2">
            <row>
                <label>Chrome 14.0</label>
                <nb_uniq_visitors>13</nb_uniq_visitors>
                ...
            </row>
            <row>
                <label>Chrome 13.0</label>
                <nb_uniq_visitors>13</nb_uniq_visitors>
                ...
            </row>
            ...
        </result>
        <result idSite="3">
            <row>
                <label>Chrome 14.0</label>
                <nb_uniq_visitors>13</nb_uniq_visitors>
                ...
            </row>
            <row>
                <label>Chrome 13.0</label>
                <nb_uniq_visitors>13</nb_uniq_visitors>
                ...
            </row>
            ...
        </result>
        ...
    </results>
    

    This does mean that any aggregating for your mean value will have to be done once you get the data but this should be relatively trivial.