We've been trying to figure out how to pull analytics filtered by campaign.
We're essentially trying to do:
but it returns:
and when we remove the segment, it works, although we can't use the data because we need it filtered.
We also tried a fallback approach, to basically pull all of the campaigns first and then get all the pages for those campaigns (segments), but it doesn't return anything either:
Can anyone give us any clue as to why this approach isn't working? We've been following the documentation, specifically the part on http://developer.piwik.org/api-reference/reporting-api-segmentation and we believe we're following all of the suggestions there.
Thank you for your help
Are you referring to campaigns, or referrers? How are the campaigns tagged?
If they are tagged like this:
you could use the advanced campaign plugin http://plugins.piwik.org/AdvancedCampaignReporting
You will then be able to create segments based on the common campaign parameters.
Hi there and thanks for sharing thoughtful advice.
Following your comment, we are tagging the campaigns using the pk_campaign parameter in the following manner:
And pulling the campaigns using the Referrers.getCampaigns API call returns:
But when attempting to pull pageviews filtered for the calcubot campaigns, the response is always blank:
Are we missing something or are we using the wrong attribute name to segment?
Also, we are not the admin of the piwik implementation and thus, can't install additional plugins or such. But I would imagine that something as basic as pulling the pageviews filtered by a campaign should be easy to accomplish without the need for plugins, specially since it's included in the documentation.
As I said, we've been going crazy trying to figure this out and any help is greatly appreciated.
by the way, what version are you on? I know... I should have asked this earlier
Our version of piwik we're working with is 2.7
I tried both of your recommendations without success. They both return blank arrays. The strange thing is that even the "segment=referrerType==campaign" segment comes back blank, which makes me think that perhaps there's something else wrong in the construction of the url string. I even tried all of the other referrer types (direct, search, website, campaign) and they all return blank.
Here are the calls:
What are your thoughts?
Hmmm... installed piwik 2.7.0 on a virtual machine, let it generate some visit by the visitorgenerator plugin. Checked the existance of campains all is well. After that I checked the actions pages report and added &segment=referrerType==campaign to the URL. The report shows data. Used the export button to export data to JSON and it worked.
It must be something instance specific, the way it looks.
Could you try it that way? If it fails, I run out of ideas without actually access to the system.
Maybe someone from the team is able to guide you trough this?
Let me check with the administrator of the Piwik implementation to see what I can dig out.
In the meantime, do you know of perhaps a better way to track traffic/activity within piwik coming from a specific referrer. We have a little app called Calcubot that sends people to a form using piwik via web links. I'm thinking that maybe we should be using something other than pk_campaign.
Your thoughts are greatly appreciated.
I heard back from Dominic, the system admin. Turns out the system version is 2.10.0.
Do you think this makes a difference?
By the way, what is your name?
I also did what you suggested of going through the admin interface (UI), pulling the Actions > Pages report and appending &segment=referrerType==campaign to the end of the URL. Nothing is returned.
Do you think that maybe the tag we're using in combination with pkcampaign could be the issue? Can we perhaps use the google-like utm params?
Also I asked the system admin Dominic if maybe he could take a look at the logs for us. Do you have any suggestions as to what to look? I'm hoping this might shed some light on this strange issue.
Thanks again as always.
Hello, I'm back with an update. I received this from the system admin:
I came across this forum post (http://forum.piwik.org/read.php?2,116865,116865#msg-116865) which might be related, where the founder Matt seems to acknowledge that segmentation doesn’t work after reports become “archived” when going back past a certain age/date.
I believe our installation has a similar configuration, where it is going and regularly deleting the older raw data/logs, and then the older visitor data can only be accessed through the “archived” reports. I can try to confirm with our admin on what the exact timeframe is for this..
Is there a chance you would be able to generate some fresh campaign hits now, so that you could retry it within a very recent timeframe when all the raw logs should still be intact?
I was wondering what your thoughts are? Is there anyway you could confirm this? We'll generate some traffic data and test the hypothesis on our end but would be helpful to have a second opinion.
Thanks again, have a good weekend!
The data is tracked and available, based on the results of the following URL:
That proves the pk_campaign is working, so don't change that part.
When you delete old visitor logs, you lose the ability to create a segment on historic data, because there is no data to segment on.
When you create segments that are processed in real time, those segments will be unavailable after clearing old visitor logs.
However, if you create segments that are pre-processed, the archived data for those new segments are kept in the archived data. I know, it doesn't help you to get segmented data from the deleted visitor logs in the past, but it does provide you a way to secure data in the future.
Do you think that would be helpfull in your case?
Yes, that sounds like a good workaround. Do you know how to setup the per-processed segment or can you share any resources about it?
There are a few things that should make it work, I write down a few options to choose from:
Let me know if any of these are working for you
We solved the puzzle! It was the archiving function that prevented the segment from working as per the documentation.
It seems like we should be able to work within the limitation of the archiving threshold of 120 days for the piwik implementation that we're working with.
Thank you very much for your help through this educating journey.
Excellent troubleshooting here @RMastop - thanks for your help :+1: