There are 2 types of quests asking to collect chips:
1 - Lotus quests (daily quests) - these tasks count collected chips both when you win and when you fail levels. It works like that because the time to complete a Lotus quest is limited.
2 - Common quests that ask to collect chips of a certain type. These quests count collected chips only when you win level.
If you fail, the counter will not be updated. Note that time to complete such quests is not limited and you can get back to these quests later!