A method of detection of stray currents using the Short Time Fourier Transformation (STFT) is presented. This particular kind of signal analysis makes the determination of changes of the spectral power density of a signal (e.g. structure to electrolyte potential) in function of time possible. The results of joint time-frequency analysis of the potential in the field of stray currents generated by tram-line are presented. The spectrogram is a composition of spectral lines of defined frequency distribution. A good correlation of localization of spectral lines corresponding to rail potential and pipeline potential in time domain is visible. These peaks may be treated as a characteristic feature of tram passing. The comparison of time and frequency localization of peaks from spectrograms is unambiguous evidence that the electric field generated by passing trams interfered on the investigated pipeline. A presented result unambiguously shows the possibility of accurate identification of source of stray currents and its interference on the metal construction.