I am having trouble setting the "Keep Page URL fragments when tracking Page URLs" option for a website. The site is tracking fine. The select box for the "Keep Page URL fragments when tracking Page URLs" option has no value selected. When I select "Yes", then click "Save", it appears to save OK. But when I go back to the config menu for that website, the option is once again unselected.
Any ideas anyone?
The value seems to be saved in the database correctly. But the saved value isn't preselected. Seems to be a bug.
I tried to reproduce but couldn't. Maybe I don't understand this part correctly:
But when I go back to the config menu for that website, the option is once again unselected.
Whatever value I select and save for a website, when I open the website again, it's always correctly preselected. Tested with latest Chrome and latest Piwik 2.16
I'm able to reproduce that on my local instance. When editing any website most of the select values are not correctly preselected. Only selection of currency and time zone is correct.
Chrome dev tools are showing this generated html for the fragment selection:
<select ng-options="key as value for (key, value) in keepURLFragmentsOptions" ng-model="site.keep_url_fragment" class="ng-pristine ng-valid"> <option value="?" selected="selected" label=""></option> <option value="0" label="No (Default)">No (Default)</option> <option value="1" label="Yes">Yes</option> <option value="2" label="No">No</option> </select>
Which browser are you using? I can prepare a patch to see if it changes something... maybe you can test it afterwards. I'll comment in a bit
Can you try the following change?
I couldn't test it since I'm on a branch and cannot switch easily but it should work:
latest Chrome on Windows 7 but doesn't work on Firefox, aswell.
Tried your proposed change, but it didn't help
@tsteur I've adjusted the branch a bit. Using integers as keys solves the problem for me. Would you check if it still works and merge it to master if so.
I think that would break it on other systems. It seems to depend whether you get from database or rather from API an integer or a string. In my case I'm getting
"ecommerce":"0". We'd basically have to convert all ng-models to integer or to string and also use the same for options. I might be able to work on this later.
@sgiehl I pushed https://github.com/piwik/piwik/commit/95e23b789543905ebc01e803dbb9a0a99b212508 and now it should always work as it will always use integers. Before you pull you can likely try to create a new site and see it wouldn't pre-select anything because it expected strings. Now it should always work with integers and work in all cases.
FYI, AFAIK it's possible this inconsistency (int VS string) comes from the MySQL adapter used (PDO vs Mysqli).