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

Custom Variables not tracked on Site Searches requests #6333

Closed
Bogun opened this issue Sep 29, 2014 · 21 comments
Closed

Custom Variables not tracked on Site Searches requests #6333

Bogun opened this issue Sep 29, 2014 · 21 comments
Labels
answered For when a question was asked and we referred to forum or answered it. Bug For errors / faults / flaws / inconsistencies etc.

Comments

@Bogun
Copy link

Bogun commented Sep 29, 2014

Hi all.
Could you please assist with the issue below.
We have some troubles with displaying visitors statistic in PIWIK.
When we in the filter choose "All Visits" we will see:
Custom Variable Name "Action" -> Custom Variable Value "Search".
image_1
But if we apply filter:
image_2
Custom Variable Value "Search" is not displaying:
image_3

Could you please help me with this issue?
What should i do to fix it?

Thank you in advance.

@EduardTrayan
Copy link

Please assist, because it's a critical blocker for our team

@mattab
Copy link
Member

mattab commented Sep 30, 2014

Maybe simply for urls containing videoportal then none of the pageviews had a custom variable set to Name=Action, Value=search ?

@EduardTrayan
Copy link

I don't think so, but we insert 2 blocks of PIWIK tracking code on one page (search results page) for purposes of tracking search as action and view search results as another action.
Our code looks like this:

<script type="text/javascript">
        var _paq = _paq || [],
             date = new Date();

        _paq.push(['setCustomVariable', 1, 'Internal ip', '###', 'page']);
        _paq.push(['setCustomVariable', 2, 'User\'s login', 'Eduard Trayan', 'page']);
        _paq.push(['setCustomVariable', 3, 'Time of view', $.format.date(date, "MM/dd/yyyy HH:mm:ss") +' (UTC' + date.getOffsetString() + ')', 'page']);
        _paq.push(['setCustomVariable', 4, 'Office', '###', 'page']);
        _paq.push(['setCustomVariable', 5, 'Content type', 'search results', 'page']);
        _paq.push(['setCustomVariable', 6, 'Action', 'search', 'page']);
        _paq.push(['setCustomVariable', 12, 'Search criteria', 'test', 'page']);
        _paq.push(['setCustomVariable', 13, 'Search results count', '15', 'page']);

        _paq.push(['trackPageView']);
        _paq.push(['enableLinkTracking']);

        if (!window.isStatisticsLoads) {
            (function(global) {
                var u=(("https:" == document.location.protocol) ? "https" : "http") + "://###/";
                _paq.push(['setTrackerUrl', u+'piwik.php']);
                _paq.push(['setSiteId', 8]);
                var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
                g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
                global.isStatisticsLoads = true;
            })(window);
        }
</script>
<!-- End Piwik Code -->

<!-- Piwik -->
<script type="text/javascript">
        var _paq = _paq || [],
            date = new Date();

        _paq.push(['setCustomVariable', 1, 'Internal ip', '###', 'page']);
        _paq.push(['setCustomVariable', 2, 'User\'s login', 'Eduard Trayan', 'page']);
        _paq.push(['setCustomVariable', 3, 'Time of view', $.format.date(date, "MM/dd/yyyy HH:mm:ss") +' (UTC' + date.getOffsetString() + ')', 'page']);
        _paq.push(['setCustomVariable', 4, 'Office', '###', 'page']);
        _paq.push(['setCustomVariable', 5, 'Content type', 'search results', 'page']);
        _paq.push(['setCustomVariable', 6, 'Action', 'view', 'page']);
        _paq.push(['setCustomVariable', 12, 'Search criteria', 'test', 'page']);
        _paq.push(['setCustomVariable', 13, 'Search results count', '15', 'page']);

        _paq.push(['trackPageView']);
        _paq.push(['enableLinkTracking']);

        if (!window.isStatisticsLoads) {
            (function(global) {
                var u=(("https:" == document.location.protocol) ? "https" : "http") + "://###/";
                _paq.push(['setTrackerUrl', u+'piwik.php']);
                _paq.push(['setSiteId', 8]);
                var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
                g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
                global.isStatisticsLoads = true;
            })(window);
        }
</script>

After page loads we can see 2 requests to PIWIK instance:

https://###/piwik.php?action_name=###&idsite=8&rec=1&r=006266&h=15&m=10&s=32&url=https://videoportalqa/search/results?q=test&_stateless_search_token=4d406d92-27b9-4195-b0d9-b16a6b0db40c&urlref=https://videoportalqa/search/results?q=test&_stateless_search_token=a199dfb4-23bb-4839-9081-73db4daac434&_id=9cb16a1aeef3ea3e&_idts=1411390092&_idvc=9&_idn=0&_refts=0&_viewts=1411977688&pdf=1&qt=0&realp=0&wma=1&dir=0&fla=1&java=1&gears=0&ag=1&cookie=1&res=1920x1080&cvar={"1":["Internal ip","###"],"2":["User's login","Eduard Trayan"],"3":["Time of view","09/30/2014 15:10:32 (UTC +03:00)"],"4":["Office","###"],"5":["Content type","search results"],"6":["Action","view"],"12":["Search criteria","test"],"13":["Search results count","15"]}&gt_ms=1000



https://###/piwik.php?action_name=###&idsite=8&rec=1&r=096369&h=15&m=10&s=32&url=https://videoportalqa/search/results?q=test&_stateless_search_token=4d406d92-27b9-4195-b0d9-b16a6b0db40c&urlref=https://videoportalqa/search/results?q=test&_stateless_search_token=a199dfb4-23bb-4839-9081-73db4daac434&_id=9cb16a1aeef3ea3e&_idts=1411390092&_idvc=9&_idn=0&_refts=0&_viewts=1411977688&pdf=1&qt=0&realp=0&wma=1&dir=0&fla=1&java=1&gears=0&ag=1&cookie=1&res=1920x1080&cvar={"1":["Internal ip","###"],"2":["User's login","Eduard Trayan"],"3":["Time of view","09/30/2014 15:10:32 (UTC +03:00)"],"4":["Office","###"],"5":["Content type","search results"],"6":["Action","search"],"12":["Search criteria","test"],"13":["Search results count","15"]}&gt_ms=1000

Everything looks good.
Could you assist please?

@mattab
Copy link
Member

mattab commented Oct 2, 2014

Please look in the Visitors > Visitor Log, hover on the pageview, on the tooltip you will the custom variables names and values. It should show the proper values?

@mattab mattab closed this as completed Oct 2, 2014
@mattab mattab added the worksforme The issue cannot be reproduced and things work as intended. label Oct 2, 2014
@EduardTrayan
Copy link

A problem was in "intelligent" behavior of PIWIK, while you search something. It parses query string and if detects search (according to internal rules) - unbinds all custom variables in this action from page uri, and we can't use filter by page url for this custom variables.

Solution: disable PIWIK search tracking in website settings "Do not track Site Search"

@mattab
Copy link
Member

mattab commented Oct 2, 2014

oh ! Sorry about that. Re-opening as it looks like a bug

@mattab mattab reopened this Oct 2, 2014
@mattab mattab added this to the Short term milestone Oct 2, 2014
@mattab mattab added Bug For errors / faults / flaws / inconsistencies etc. and removed worksforme The issue cannot be reproduced and things work as intended. labels Oct 2, 2014
@EduardTrayan
Copy link

I think that bug is not in name of variables.
Steps to reproduce:

  1. Register site at PIWIK admin panel with SITE SEARCH setting: Site Search tracking enabled
  2. Create route on your registered website like
http://site.com/search?q=query_string
  1. On page, which opens by link above, add some js code for registering some custom variables
  2. Open page above
  3. Go to PIWIK => Visitor => Custom variables
  4. See your custom variables
  5. Create custom segment, which will contain definition "Page url Contains site.som" and apply this segment

Actual result: you don't see your custom variables
Expected result: you can see your custom variables.

I think PIWIK doesn't bind source url with custom variables in case of search performing

@mattab
Copy link
Member

mattab commented Oct 6, 2014

@EduardTrayan Right that's correct. See also: Add "Download file URL" and "Outlink URL" segments #4103

@EduardTrayan
Copy link

Our solution is disable SITE SEARCH setting at website settings at admin panel.

How do you think, this is a bug, or feature?

@mattab mattab changed the title Custom Variables. Value "Search" in Action variable is not displaying. When Segmenting for Page URL, it should also include Site Searches as well as pageviews Oct 7, 2014
@mattab
Copy link
Member

mattab commented Oct 7, 2014

@EduardTrayan sorry I got confused there. Now I read again your comment:

unbinds all custom variables in this action from page uri, and we can't use filter by page url for this custom variables.

Can you please check in the log_link_visit_action table for the row of this site search request, whether the custom variables are there in the database? You can also check in Visitors>Visitorlog on hover onthe Site Search request, the tooltip should list the custom variables. are they all there?

@mattab mattab changed the title When Segmenting for Page URL, it should also include Site Searches as well as pageviews Custom Variables not tracked on Site Searches requests Oct 7, 2014
@EduardTrayan
Copy link

@mattab If a enable Site Search tracking
tracking

In Visitors > Visitorlog ,without custom segment about page url, I see all my custom variables
custom

But you can see that this action doesn't contain url address which it came from

And if I create&apply custom segment with expression "Page url contains ..." I can't see custom variables from action from screen

If I disable site search tracking everything works as expected

@mattab
Copy link
Member

mattab commented Oct 7, 2014

And if I create&apply custom segment with expression "Page url contains ..." I can't see custom variables from action from screen

Do all custom vars still show in the tooltip in the Visitor Log when you segment?

@EduardTrayan
Copy link

Yes, they still show, but on page "Visitors > Custom variables" with page url custom segment we can't see this variables.

Also on page "Visaitors > Visitors Log" without custom segment I see following actions

c1
c2
c3

But with custom segment I see only
c1

@EduardTrayan
Copy link

@mattab Could you please provide information about current status of our issue?

@mattab
Copy link
Member

mattab commented Oct 17, 2014

Not scheduled yet, but we hope to fix it in the next few months. If you need it faster please sponsor the work by contacting us at http://piwik.org/consulting/

@tsteur
Copy link
Member

tsteur commented Feb 4, 2015

Re-opening as it is indeed a bug, that Site Search requests are using Custom Variables slots that may be reserved. In this case we should throw an exception in the browser console or something?

Are we actually using Custom Variables there for this? We should rather fix this hack.

@mattab
Copy link
Member

mattab commented Feb 9, 2015

Are we actually using Custom Variables there for this? We should rather fix this hack.

Actually not I was wrong... see https://github.com/piwik/piwik/blob/master/js/piwik.js#L3647-L3656

@mattab
Copy link
Member

mattab commented Feb 9, 2015

Hi @EduardTrayan this issue is getting too long and I'm lost. Maybe the issue is caused becasue you use two tracking codes? Or can you reproduce the issue with only one tracking code? if so please note the steps to reproduce and we'll take a look

@AlexanderGirgis
Copy link

Hi @mattab

I was trying to get a site search with local variables too, when I found this issue. After a brief look at the code I think the problem might be that CustomVariables are missing from the call https://github.com/piwik/piwik/blob/master/js/piwik.js#L5026-L5030 of the funcion you mentioned, however I can't set up a full stack to test it at the moment. However this feature is key to my project, I hope that helps solving the problem.

@mattab
Copy link
Member

mattab commented Mar 1, 2015

Here is what we need to solve the problem / bug:

  • a clear list of steps to reproduce the issue (maybe a HTML file or two, with minimal content and the piwik code to reproduce)
  • a description of what you get VS what you expected to get

If we can reproduce the issue then we will for sure aim to fix it quickly!

@mattab
Copy link
Member

mattab commented Apr 7, 2015

Please createa new bug report with steps to reproduce, and for sure we will take a look at it - thanks for your understanding

@mattab mattab closed this as completed Apr 7, 2015
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Apr 7, 2015
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. Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

5 participants