The Scottish government still intends to introduce its named person scheme despite a Supreme Court ruling.
The controversial proposals would appoint a single person - usually a teacher or health visitor - to look out for the welfare of every child.
But the Supreme Court ruled that part of the legislation relating to data sharing breached human rights laws.
Deputy First Minister John Swinney said the necessary changes to the scheme would be made.
Mr Swinney told the BBC: "What the government is going to do is to consider carefully the judgement of the Supreme Court, which requires us to make some changes to the information sharing arrangements of the named person scheme.
"Then we will proceed to implement the named person scheme, which the Supreme Court judged to be unquestionably legitimate."
Campaigners against named person appealed to the Supreme Court in London after their case was dismissed as "hyperbole" by the Court of Session in Edinburgh last year.
They have described named person as a "state snooper" scheme that would undermine parents and divert resources away from the most vulnerable children.
But the Scottish government accused opponents of misrepresenting the proposals, and insisted they would help to protect vulnerable children while giving a single point of contact for parents who needed help or advice.
In its ruling, Supreme Court judges allowed the campaigners' appeal and said the legislation made it "perfectly possible" that confidential information about a young person could be disclosed to a "wide range of public authorities without either the child or young person or her parents being aware".
Right to privacy
This meant that the data sharing part of the legislation was "incompatible with the rights of children, young persons and parents" under Article 8 of the European Convention on Human Rights (ECHR), which deals with the right to privacy and a family life.
But the judges also said that the purpose of the legislation was "unquestionably legitimate and benign" and gave Scottish ministers "an opportunity to correct the defects".
Mr Swinney said named person was an "important scheme that is designed to support the wellbeing of young people in Scotland, to provide them with the support when they require it".
He added: "It has been very broadly supported by the Scottish Parliament, and it will be taken forward by the Scottish government."
The scheme was originally to be rolled-out across the country by 31 August, but the Supreme Court ruling means that will not now be possible.
However, BBC Scotland understands that the government is hopeful the legislation can be relatively easily redrafted to make it fully compliant with the ECHR, and that it could potentially be introduced before the end of the year assuming the changes are approved by the Scottish Parliament.
What are opponents of named person saying?
Lawyer Elaine Motion, who represented The Christian Institute and six other petitioners in the legal challenge, said: "This is a highly significant and extremely unusual judgement. Successful challenges to legislation are very rare.
"In layman's terms, the Supreme Court has said that the Scottish Government has overstepped the line drawn by Article 8 to protect and respect private and family life."
The Christian Institute co-ordinated the successful legal action, with its director Colin Hart saying: "This ruling is crystal clear that the named person scheme's cavalier approach to handling private information is unlawful and must not happen."
Simon Calvert, spokesman for the No to Named Persons (NO2NP) campaign group, claimed: "The Big Brother scheme is history.
"It's wonderful news for mums, dads and children all across Scotland who no longer have to worry about this unjustified invasion of their private lives."
Scottish Conservative leader Ruth Davidson said the "important ruling by the most senior court in the land" was a "victory for campaigners who have exposed this from the outset as illiberal, invasive and deeply-flawed".
She added: "We have consistently argued against the named person legislation on grounds of principle and practicality. I hope today's ruling will make the SNP stop and think again."
Why does the Scottish government want to introduce named person?
The Scottish government wants Scotland to be "the best place in the world for children to grow up".
It has said that most children and young people get all the help and support they need from their parents, wider family and community, but sometimes they might need a bit of extra support.
As part of its Getting it Right for Every Child strategy, the government proposed giving all children and young people from birth to 18 years access to a named person under the Children and Young People (Scotland) Act 2014.
The Scottish government says the named person is intended to be single point of contact if a child or their parents want information or advice, or if they want to talk about any worries and seek support.
They will also be a point of contact for other services if they have any concerns about a child's wellbeing.
The law had been due to come into force across the country on 31 August of this year, although the policy had already been rolled out in parts of Scotland, including Highland, Edinburgh, Fife, Angus and South Ayrshire.
Mr Swinney said the government would start work to amend the legislation "immediately", so that the scheme can still be rolled out "at the earliest possible date".
He welcomed the judgement as a sign that "the attempt to scrap the named person service has failed".
What do other parties think?
Labour is broadly in favour of named person in principle, but has previously called for a "pause" to ensure it is introduced "properly and proportionally".
Education spokesman Iain Gray said the handling of the scheme had been "a shambles from the very beginning".
He said: "Labour will always support the need to protect vulnerable children and ensure that families get the support they need and deserve.
"In light of this ruling, however, the implementation of this scheme must be paused for as long as it takes to sort it properly. That is the case Scottish Labour have made for many months now and it is more compelling than ever following the court decision."
Ross Greer of the Scottish Greens said his party would continue to give its full support to named person, but called on the Scottish government to do more to build public confidence and better explain what the scheme means in practice.
The Scottish Liberal Democrats submitted a motion calling for parliament to be urgently recalled.
Education spokesman Tavish Scott said: "A recall of parliament is the only way to ensure that reforms receive the scrutiny required. This is not a decision for a minority minister to make in his office. It needs full parliamentary approval."