@joseariel opened this Issue on March 9th 2015

Hello,

We've been trying to figure out how to pull analytics filtered by campaign.

We're essentially trying to do:

/?module=API&method=Actions.getPageUrls&segment=referrerName=@calcubot&idSite=98&period=day&date=2014-11-05&format=JSON&token_auth=...&expanded=1

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:

?module=API&method=Actions.getPageUrls&segment=referrerName=@cb-calcubot-id%3D292%3Acb-uid%3Dnull,referrerName=@cb-calcubot-id%3D292%3Acb-uid%3D567&idSite=98&period=day&date=2014-11-05&format=JSON&token_auth=...&expanded=1

returns:

[]

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

@RMastop commented on March 11th 2015 Contributor

Hi @joseariel,
Are you referring to campaigns, or referrers? How are the campaigns tagged?

If they are tagged like this:
http://www.example.com/webshop/?utm_source=source&utm_medium=medium&utm_term=term&utm_content=content&utm_campaign=name
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.

@joseariel commented on March 11th 2015

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:

http://www.example.com/webshop/?pk_campaign=cb-calcubot-id%3D293%3Acb-uid%3D1

And pulling the campaigns using the Referrers.getCampaigns API call returns:

/?module=API&method=Referrers.getCampaigns&idSite=98&segment=referrerName=@cb-calcubot-id &period=day&date=2014-10-15&format=JSON&token_auth=...&expanded=1

[
{
label: "cb-calcubot-id=292:cb-uid=null",
nb_uniq_visitors: 3,
nb_visits: 3,
nb_actions: 113,
max_actions: 66,
sum_visit_length: 3048,
bounce_count: 0,
nb_visits_converted: 0
},
{
label: "cb-calcubot-id=292:cb-uid=567",
nb_uniq_visitors: 1,
nb_visits: 2,
nb_actions: 45,
max_actions: 31,
sum_visit_length: 1407,
bounce_count: 0,
nb_visits_converted: 0
},
{
label: "cb-calcubot-id=292:cb-uid=129",
nb_uniq_visitors: 1,
nb_visits: 1,
nb_actions: 3,
max_actions: 3,
sum_visit_length: 147,
bounce_count: 0,
nb_visits_converted: 0
}
]

But when attempting to pull pageviews filtered for the calcubot campaigns, the response is always blank:

/?module=API&method=Actions.getPageUrls&segment=referrerName=@calcubot&idSite=98&period=day&date=2014-11-05&format=JSON&token_auth=...&expanded=1

[]

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.

@RMastop commented on March 11th 2015 Contributor

Hi @joseariel,

The segment you need for getting all campaigns would be:
segment=referrerType==campaign
To get the data for all calcubot campaigns would be:
segment=referrerType==campaign;referrerName=@calcubot

Could you give it a try?

@RMastop commented on March 12th 2015 Contributor

by the way, what version are you on? I know... I should have asked this earlier

@joseariel commented on March 12th 2015

Hello,

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:

/?module=API&method=Actions.getPageUrls&idSite=98&period=day&date=2014-11-05&format=JSON&token_auth=...&expanded=1&segment=referrerType==campaign

=> []

/?module=API&method=Actions.getPageUrls&idSite=98&period=day&date=2014-11-05&format=JSON&token_auth=...&expanded=1&segment=referrerType==campaign;referrerName=@calcubot

=> []

What are your thoughts?

@RMastop commented on March 12th 2015 Contributor

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?

@joseariel commented on March 12th 2015

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.

@joseariel commented on March 13th 2015

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?

@joseariel commented on March 13th 2015

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.

@joseariel commented on March 13th 2015

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!

@RMastop commented on March 15th 2015 Contributor

The data is tracked and available, based on the results of the following URL:
/?module=API&method=Referrers.getCampaigns&idSite=98&segment=referrerName=@cb-calcubot-id &period=day&date=2014-10-15&format=JSON&token_auth=...&expanded=1

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?

@joseariel commented on March 16th 2015

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?

Thanks

@RMastop commented on March 16th 2015 Contributor

There are a few things that should make it work, I write down a few options to choose from:

  • You need to be a super user on the instance (selectable item is shown in the top right corner where you can select pre-process or live) (could be kind of hard to request a super user on a shared instance)
  • The admin can set the following setting in config.ini.php:
    enable_create_realtime_segments = 0
    This setting will make sure all segments that will be created from the moment the setting is implemented are based on pre-processed segments. (need to recreate sgments)
  • The admin can set the following setting in config.ini.php:
    Segments[]="referrerName=@cb-calcubot-id"
    This setting makes sure the segment is pre-processed on every archiving run.

Let me know if any of these are working for you

@joseariel commented on March 26th 2015

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.

@RMastop commented on March 26th 2015 Contributor

Any time!

@mattab commented on April 8th 2015 Owner

Excellent troubleshooting here @RMastop - thanks for your help :+1:

This Issue was closed on April 8th 2015
Powered by GitHub Issue Mirror