Details of people's online activity will have to be stored for a year under the government's proposed new spying laws.
Firms will be required to store web users' activity, including being on social media, for at least 12 months under the new draft Investigatory Powers Bill.
In a bid to tackle people's privacy concerns, the government is promising strict safeguards, which include banning councils from accessing people's internet connection records (ICRs).
Online activity will be stored for a year under the new Investigatory Powers Bill
The bill will also see a new criminal offence of "knowingly or recklessly obtaining communications data from a telecommunications operator without lawful authority".
It will carry a maximum sentence of two years in prison and will apply to all bodies who can acquire data under the bill.
The draft bill will be published in the House of Commons on Wednesday.
Officials said that it is not intended to cover genuine mistakes or administrative errors, but added that it "makes clear that it is unlawful for councils to access communications data for trivial matters".
Communications data - the who, where, when and how, but not the content - can be requested by town halls to prevent or detect crime.
They are responsible for investigating a range of offences such as scams that target the elderly, rogue trading, environmental offences and benefit fraud.
Laws introduced last year meant council requests for communications data must be signed off by a magistrate.
Speaking on BBC's The Marr Show on Sunday, Theresa May pledged not to let spies look through someone's internet history.
It had previously emerged that authorities had used snooping powers to spy on dog walkers suspected of not clearing up after their pets and possible breaches of the smoking ban.
A Government source said: "Communications data is an essential tool for the full range of law enforcement activity, including serious offences investigated by local authorities like rogue traders and benefit fraud.
"Sometimes communications data is the only way to identify offenders, particularly where offences are committed online.
"But it is important that people understand that communications data is only ever used in a necessary, proportionate and accountable way.
"That is why the draft Bill contains strengthened safeguards making it clear under what circumstances local authorities can access communications data – and confirms they are banned from obtaining internet connection records," the Press Association reports.
ICRs are likely to be one of the most closely scrutinised elements of the legislation, which will attempt to bring tactics available to spies and police fighting terrorism and serious crime in the digital age under one legal umbrella for the first time.
Described as the internet equivalent of a phone bill, the ability to obtain the data is seen as crucial as communications increasingly shift online.
ICRs would allow the police to see that a person has visited bbc.co.uk, google.co.uk or facebook.com, but not what articles they have read, searches they have made or profiles they have viewed.
Security services will retain the capacity to intercept the content of communications after obtaining a warrant.
The draft document will be looked at by both Houses of Parliament before the final bill is voted on next year.