Custom Dimension Data Inserted into the Wrong Columns

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

Custom DImension Test var _paq = _paq || []; _paq.push(["setDomains", ["*"]]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//"; _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]);
        <noscript><p><img src="//xxxxxxx....piwik/piwik.php?idsite=1898" style="border:0;" alt="" /></p></noscript>
    <!-- End Piwik Code -->

    <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;

The tracking url sent is:


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

Custom idccustomdimension Column Value
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 an 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.
Thsi occurs for both visit and action scoped custom dimension data.

What a program? Maybe you forgot to attach something?

1 Like

It looks like I can only upload image format files, so I can’t attach the code example. But when I edit the post I can see my full text including the program.

Adding a screen shot of the code

Here are more details

and possible cause

The database records

The custom_dimensions table

See following posts for details

Please continue the discussion here: Custom Dimensions are Inserted into the Wrong Columns · Issue #9931 · matomo-org/piwik · GitHub