We consider the situation with a survival or more generally a counting process endpoint for which we wish to investigate the effect of an initial treatment. Besides the treatment indicator we also have information about a time-varying covariate that may be of importance for the survival endpoint. The treatment may possibly influence both the endpoint and the time-varying covariate, and the concern is whether or not one should correct for the effect of the dynamic covariate. Recently Fosen et al. (Biometrical J 48:381-398, 2006a) investigated this situation using the notion of dynamic path analysis and showed under the Aalen additive hazards model that the total effect of the treatment indicator can be decomposed as a sum of what they termed a direct and an indirect effect. In this paper, we give large sample properties of the estimator of the cumulative indirect effect that may be used to draw inferences. Small sample properties are investigated by Monte Carlo simulation and two applications are provided for illustration. We also consider the Cox model in the situation with recurrent events data and show that a similar decomposition of the total effect into a sum of direct and indirect effects holds under certain assumptions.