Affiliate Tracking with Piwik

I know this has been asked before, but I haven’t found a solid solution via the forum. I’m hoping some of you experience Piwik users can help me out.

I’m hoping to track affiliate conversions via goals in Piwik. I only have the ability to bridge the conversion data via sub id’s and postbacks. I won’t always have the ability to post a conversion pixel on the advertisers site. However, I can fire the pixel via a postback. In fact, that’s what I’m currently doing. I’ve generated a unique id per visitor and pass it to Piwik with a custom variable. Then, on a conversion, fire the Piwik’s pixel with the custom variable value, goal id and revenue. Piwik is collecting the data, but not associating the custom variables and campaign data. It’s just grouping it under goals. I need to trace the custom variable right back to the campaign keyword that was passed in via utm_ variables.

So… my questions are:

  1. Is there a way to get Piwik’s unique user id (I think it’s the cid) via Javascript or do I have to use the API?
  2. How do I tie my conversion data to the campaign data with custom variables? Is this even possible? If not, will the cid do the job?

Ideally I’d like to do this all via Javascript (some pages are hosted on a static CDN), but can resort to PHP if needed.

Thanks in advance for your help!

  1. you can use getVisitorId javascript function to get the visitor ID
  2. Not sure what you really mean. Conversions are attributed to Custom Variables, and to Referrer (website OR campaign OR search).