Set campaign name and keyword using javascript api

Hi all,

I’m new in this forum. I’ve been using Piwik for the last 3 months and it’s great! :slight_smile:

I have a site accesible through several subdomains. Each subdomain represents a different campaign (,…).

Actually I’m using a custom variable to track these campaigns but I would like to use the native campaign support already present in Piwik.

I found I can manually call piwik.php and set the campaign name using the _rcn parameter, but, I’m using the Javascript API and I can’t find a way to set the campaign name, so…

How can I set the campaign name using the Javascript API? I think it’s not possible. In that case, please take it as a feature request.

Thank you very much,


You can use:

setCampaignNameKey(name) - Set campaign name parameter(s). (Help: Customize Campaign name parameter names)
setCampaignKeywordKey(keyword) - Set campaign keyword parameter(s). (Help: Customize Campaign keyword parameter names)

see more:

Thanks for answering, but I can’t imagine how to use those functions to solve my problem because campaign name is part of the subdomain, it isn’t in the query string.

I can read subdomain (==campaign name) using Javascript, and i was expecting it existed a function ‘setCampaignName’ (instead of setCampaignNameKey).

Actually what I’m doing is, using Javascript, to extract subdomain, append “#pk_campaign=subdomain” to the url, and finally use setCustomUrl(). I don’t like it because I’m modifying the url reported to Piwik.

Oh you are right there is no function to set the campaign name and keyword in JS ?

Please create a ticket in the roadmap “1.8.x” and we will work on it soon.