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 Dimensions are Inserted into the Wrong Columns #9931

Closed
3dmashup opened this issue Mar 15, 2016 · 10 comments
Closed

Custom Dimensions are Inserted into the Wrong Columns #9931

3dmashup opened this issue Mar 15, 2016 · 10 comments
Assignees
Labels
worksforme The issue cannot be reproduced and things work as intended.
Milestone

Comments

@3dmashup
Copy link

The Piwik application (vsn 2.16.1-b2) is inserting the custom dimension data into the wrong columns. To reproduce
Configure a Web site with 15 visit dimension and 15 action dimensions. Create a Web site with 7 visit dimensions and 7 action dimensions . Run the following test program

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>Custom DImension Test</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <!-- Piwik -->
            <script type="text/javascript">
              var _paq = _paq || [];
              _paq.push(["setDomains", ["*.wrap.co"]]);
              _paq.push(['trackPageView']);
              _paq.push(['enableLinkTracking']);
              (function() {
                var u="//tim-piwik01.wrap.co/piwik/";
                _paq.push(['setTrackerUrl', u+'piwik.php']);
                _paq.push(['setSiteId', 1898]);
                var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
                g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
              })();

              function sendCustomDimensions(v1,v2,v3,v4,v5,v6,v7) {
                  _paq.push(['setCustomDimension', '1', v1]);
                  _paq.push(['setCustomDimension', '2', v2]);
                  _paq.push(['setCustomDimension', '3', v3]);
                  _paq.push(['setCustomDimension', '4', v4]);
                  _paq.push(['setCustomDimension', '5', v5]);
                  _paq.push(['setCustomDimension', '6', v6]);
                  _paq.push(['setCustomDimension', '7', v7]);
              };

            function sendEvent(category, action, label, value) {
                _paq.push(['trackEvent', category, action, label, value])  
            };

              function sendPageView(title) {
                window._paq.push(['trackPageView', title]);

              };
            </script>
            <noscript><p><img src="//xxxxxxx....piwik/piwik.php?idsite=1898" style="border:0;" alt="" /></p></noscript>
        <!-- End Piwik Code -->

    </head>
    <body>
        <div>Custom Dimension Test</div>

        <script type="text/javascript">
            var d = new Date();
            var n = d.toUTCString(); 
            var cards = [ 'card 1 ' + n , 'card 2 '+ n];
            var dimensions = [ "dim 1", "dim 2", "dim 3", "dim 4", "dim 5", "dim 6", "dim 7"];

            for (  i = 0; i <  cards.length; i++) {
                d = [];
                for ( j = 0; j < dimensions.length;  j++) {
                    d[j] = dimensions[j] + ' ' + n;
                }
                sendCustomDimensions(d[0],d[1],d[2],d[3],d[4],d[5],d[6]);
                sendPageView(cards[i]);
            };

        </script>
    </body>
</html>

The tracking url sent is:

https://xxxxxxxxx/piwik/piwik.php?action_name=card%202%20Tue%2C%2015%20Mar%202016%2021%3A49%3A54%20GMT&idsite=1898&rec=1&r=634934&h=14&m=49&s=55&url=http%3A%2F%2Flocalhost%3A8383%2FPiwik_Test%2FDim2.html&_id=394575a3f7d8d6d4&_idts=1458067748&_idvc=3&_idn=0&_refts=0&_viewts=1458078595&send_image=0&pdf=0&qt=0&realp=0&wma=0&dir=0&fla=0&java=1&gears=0&ag=0&cookie=1&res=3840x2160&dimension1=dim%201%20Tue,%2015%20Mar%202016%2021:49:54%20GMT&dimension2=dim%202%20Tue,%2015%20Mar%202016%2021:49:54%20GMT&dimension3=dim%203%20Tue,%2015%20Mar%202016%2021:49:54%20GMT&dimension4=dim%204%20Tue,%2015%20Mar%202016%2021:49:54%20GMT&dimension5=dim%205%20Tue,%2015%20Mar%202016%2021:49:54%20GMT&dimension6=dim%206%20Tue,%2015%20Mar%202016%2021:49:54%20GMT&dimension7=dim%207%20Tue,%2015%20Mar%202016%2021:49:54%20GMT&gt_ms=1

The tracking url correctly matches the dimension and values.
On querying the database the log_link_visit_action_table has the misplaced values

Custom idcustomdimension Column Value
Dimension
Column Name
1 1 dim%201%20Tue,%2015%20Mar%202016%2021:49:54%20GMT
2 3 dim%203%20Tue,%2015%20Mar%202016%2021:49:54%20GMT
3 5 dim%205%20Tue,%2015%20Mar%202016%2021:49:54%20GMT
4 7 dim%207%20Tue,%2015%20Mar%202016%2021:49:54%20GMT
5 9 null
6 11 null
7 13 null

The idcustomdimension value was obtained by querying the custom_dimensions table and matching the scope and index for this web site.
It appears that the problem is the dimension index value is not being used to place the data into the correct column, its more likely that the custom dimension idcustimdimension value is being used. This occurs for both visit and action scoped custom dimension data.

@tsteur
Copy link
Member

tsteur commented Mar 16, 2016

There is in general the idcustomdimension and there is an index for each custom dimension. The idcustomdimension is what you see in the API, eg dimension2. The index defines in which column it should actually go. For example dimension2 might be stored in custom_dimension_1 column.

Configure a Web site with 15 visit dimension and 15 action dimensions. Create a Web site with 7 visit dimensions and 7 action dimensions . Run the following test program

To reproduce this we'd need to know whether we're supposed to create first all visit dimensions or first all action dimensions or whether you created them in a specific order? Otherwise the mapping of idcustomdimension to an index will be different in our test.

@3dmashup
Copy link
Author

[Try](url
<img width="948" alt="screenshot 2016-03-29 07 45 35" src="https://cloud.githubusercontent.com/assets/454051/14112149/6232014c-f582-11e5-84fd-35690040ec40.png") creating the custom dimensions in pairs of 1 visit, 1 action and repeat until you have 7 of each. This will ensure that the idcustomdimension value doesn't always match the dimension index. Then you can see if the custom dimension values a placed in the correct columns.

@3dmashup
Copy link
Author

screenshot 2016-03-29 07 45 35

@3dmashup 3dmashup reopened this Mar 29, 2016
@3dmashup
Copy link
Author

Didn't mean to close the issue. How does idcustomdimension map to the database columns? Surely for each dimension the index column value should determine how the value maps to each column custom_dimension_1, custom_dimension_2, .... ?
screenshot 2016-03-29 10 22 15

@tsteur
Copy link
Member

tsteur commented Mar 29, 2016

Surely for each dimension the index column value should determine how the value maps to each column custom_dimension_1, custom_dimension_2, .... ?

Not exactly. The id in custom_dimension_1 maps to idcustomdimension for the given idSite. The index column in custom_dimenions table actually references to the correct column in log_visit / log_link_visit_action.

@3dmashup
Copy link
Author

Thanks for the clarification, please can you confirm the that you can reproduce the problem I'm seeing.

@mattab mattab added this to the 2.16.x (LTS) milestone Mar 31, 2016
@mattab mattab added Bug For errors / faults / flaws / inconsistencies etc. Waiting for user feedback Indicates the Matomo team is waiting for feedback from the author or other users. labels Mar 31, 2016
@tsteur tsteur removed the Waiting for user feedback Indicates the Matomo team is waiting for feedback from the author or other users. label Mar 31, 2016
@tsteur
Copy link
Member

tsteur commented Mar 31, 2016

I will try to reproduce it now but looking at the screenshots you posted everything looks good

@tsteur
Copy link
Member

tsteur commented Mar 31, 2016

Works as expected for me.

screenshot at apr 01 08-47-00
screenshot at apr 01 08-47-13
screenshot at apr 01 08-47-34

Just to mention it again custom_dimension_7 doesn't mean it will be stored in db column custom_dimension_7 as it can reference to either log_visit table or log_link_visit_action table.

@tsteur tsteur closed this as completed Mar 31, 2016
@tsteur tsteur added worksforme The issue cannot be reproduced and things work as intended. and removed Bug For errors / faults / flaws / inconsistencies etc. labels Mar 31, 2016
@3dmashup
Copy link
Author

Ok, thanks for the investigation. What decides where the value for custom_dimension_7 for an action scoped custom dimension is stored?

@tsteur
Copy link
Member

tsteur commented Mar 31, 2016

index column in custom dimensions table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

3 participants