Visitor_id not the same on different domains/sites


I use Piwik to track form-signups on different websites.
My forms are embedded in an iFrame and i put the same tracking-code
on both the Top and the iFrame. The domains is not the same, but i have
enabled third-party cookies.

The tracking works fine… I can see the same visitor visits both the top and the iframe
when visiting a page with the iframe.

But! When i run Piwik.getAsyncTracker().getVisitorId() on the Top-site it returns
a ID, but that ID is not the same in the iFrame.
I use the Visitor_id to track form signups and the right visitor_id is the id on the top page.

It look likes it creates two coookies

I hope you guys understands my problem. If not… Then ask me :slight_smile:

Seeing as the iframes are from different domains, the cookies will be different. You would need to add code so that Piwik is tracking only one siteID. There’s no way to make the cookies the same - that’s the way cookies work.

I guess another way is to make both frames come from the same domain. Use PHP to grab the contents of the other frame and then serve it from the same domain. Just a shot in the dark.

Hi @Valdhor.

Thanks for taking time.

I’ts not possible for me to do.
The strange thing is , on Piwik it sees the same person on both Top and iFrame, but the cookies gets the wrong visitor_id.
Is there some way (in javascript) i can ask Piwik to give me the visitor_id from the server ?

I think if you use the JS tracking API you’ll get the incorrect ID. If it was me I would create an AJAX call to the server to getVisitorID().

@Valdhor When you say server… Did you my piwik server or the application-server (which in the iframe) or the top-page (the page with the iFrame) ? :slight_smile:

Here is som more information

When retriving Visitor_id from javascript is shows me 761a64379b14925d

When looking in Piwik it shows 6c5144487351cadb

I think 6c5144487351cadb is the visitor_id the person got first time visiting.

I meant the Piwik Server. That’s the only one that would be able to respond to a getVisitorID() call.

I added the PHP sdk to the server and made a PHP-file which returning getVisitorID().
Its not returning the right ID

In that situation you are probably better creating a Visitor ID yourself and then use that for both frames. I can’t really see any other way to do it.