If you go on a tour organised by the ship or by a private registered Russian tour company (like Alla, Red October, Anastasia or Den Rus) then you do not need a visa. If you want to step off the ship by yourself then you do.
Also, To exit and return to the ship in St. Petersburg, passengers booked on shore excursions are required to present their tour tickets and BOTH their passport and A PHOTOCOPY OF THE FIRST PAGE OF THEIR PASSPORT.
On your way out of the ship you will have to pass through the immigration office; here you should present your passport, a tour ticket for the first day and a photocopy of that page of your passport which contains your photograph and personal details. The immigration officer will keep the photocopy in his office and return your passport and tour ticket to you. After checking the documents, the officer will give you a red laminated card which is your pass into the city. The card is given to each participant separately!
When you pass through the immigration office this evening on your way back to the ship you must show your passport and the red laminated card to the officer, who will retain the latter document.
On the second day of your tour, the driver and your guide will again be waiting for you at the ship. You will have to pass through the immigration office once more, but this time you will present your passport and the tour ticket only (for the second day); a photocopy is not required. You will be given a red laminated card once more.