Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS method to specify value of campaign parameters #9688

Closed
ghost opened this issue Feb 3, 2016 · 7 comments
Closed

JS method to specify value of campaign parameters #9688

ghost opened this issue Feb 3, 2016 · 7 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@ghost
Copy link

ghost commented Feb 3, 2016

Hello,

It would be good to have possibility to specify value of campaign parameters (like pk_campaign) using Java Script Tracking Client method. Actually it can be done only via HTTP Tracker parameters, which is not convenient way.

This idea came just from real life example.

@quba
Copy link
Contributor

quba commented Feb 3, 2016

Actually, you can. See http://piwik.org/faq/how-to/faq_120/

@ghost
Copy link
Author

ghost commented Feb 3, 2016

Sorry, I meant method to specify value of campaign parameters, will update issue in a moment.

@ghost ghost changed the title JS method to specify campaign parameters JS method to specify value of campaign parameters Feb 3, 2016
@quba
Copy link
Contributor

quba commented Feb 3, 2016

It's rather a hack, but should work.

_paq.push(['setCustomUrl', document.URL + '&pk_campaign=campaignName']);

@tsteur
Copy link
Member

tsteur commented Feb 3, 2016

Can you explain the use case a little? It would be nice to know what is expected to happen etc. Setting campaign parameters might create new visits etc so it would be good to know a little more about the background.

@ghost
Copy link
Author

ghost commented Feb 4, 2016

It is a question and use case from customer, I'll paste email content:

Do you know if it is possible to set the value of the pk_campaign over the API?
For example: I have a new visitor, and I don’t take the value of the pk_campaign parameter from the URL. However I know that the value of the pk_campaign for this visit should be campaign_1. Can I set through the Piwil API the value of the pk_campaign for this visit to campaign_1?

@tsteur
Copy link
Member

tsteur commented Feb 4, 2016

Got it, what @quba mentioned in #9688 (comment) would be the current way to do it. It's a little hack but not too bad, that's what the method is there for...

Someone has to be very carefully with the implementation as when set to late, and already a tracking request was sent, we'd create too many visits all the time. Basically we would create for each visit 2 visits (one with campaign, and one without).

Not sure if we can close this issue, or should create an FAQ for this (if not exists yet).

We'd probably not add a method for this as it may result in too many visits tracked when not used correctly. Also not sure how it would work when say someone does setCampaignParameter(name, ...) followed by setCustomUrl(url) ... etc. Should we still apply the campaign to the custom url or would setCustomUrl overwrite this again etc. For now it would be best to go with @quba suggestion

@mattab
Copy link
Member

mattab commented Mar 31, 2016

Hi @tomasztomik

  • I suppose we don't need a new JS function as setCustomUrl sounds good enough in this case.
  • if you would like to suggest a new small FAQ for this question/use case, please share your suggestion here or privately, and i'll be glad to add this new FAQ 👍

@mattab mattab closed this as completed Mar 31, 2016
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Mar 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

3 participants