Post the SAME info to 2 Websites (SiteIds)

Hi Guys,

I’ve searched everywhere for the answer to this, but no answers.

I am trying to use the one script to send the tracking info to 2 seperate Websites within Piwik - ie. 2 site IDs.

The reason is: We have a number of sites (Domains) that are tracked. We have one Website (call it SiteId 1) set up in Piwik that tracks visitors accross all domains. But I would like to also have the data seperated for each domain, so I have Websites set up for each domain.

How do I send the tracking info to SiteId 1 and the SiteId for that domain using the javascript method.

EG:
www.domain1.com and www.domain2.com are both tracked against the Website in Piwik called “All Sites” with the SiteId 1 (idSite=1)

That works fine with the script on both domains.

I also need www.domain1.com to also have its own seperate stats tracked in the Website in Piwik called (Domain 1) with the SiteId 2 (idSite=2).

I’ve tried a number of things including inserting the script twice into the site, one with Siteid set to 1 and once set to 2, but this did not work.

That did work however with the image pixel - using 2 pixels, but I need to do it with the script.

Has anyone done this?

See the doc: JavaScript Tracking Client: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

Thanks, I tried that script on that link exactly as it is, with my URLs and Ids but it didn’t track either sites.

Is the an example of the full working script somewhere?

Alternatively, we can do it with 2 pixels, but this causes issues on our SSL pages - as they don’t load in https - so is there a method of using the pixels so that they use https on the secure pages? - even if it were a piece of PHP that switched them?

Look on piwik.org. we track in demo.piwik and demo2.piwik at same time.