Cluster or group randomized trials (CRTs) are increasingly used for behavioral as well as system-level interventions in many areas e.g. medicine, psychotherapy, policy, and health service research etc. Sample size determination for each level at the design stage is always a key requirement for any intervention trial including CRT. This work addresses this important issue for a four-level longitudinal CRT via detecting the intervention effect over time. A random intercept and random slope mixed effects linear regression model, including a time-by-intervention interaction is used for modeling. Closed-form expression of the power function and sample size for each level are determined to detect the interaction effect. Other than statistical power consideration, several other factors need attention while designing such CRTs. Optimal allocations accounting for subject attrition and cost constraints have been determined here. How sample size determination based on fixed and random slope models affects when between-subject variations in outcome are anticipated to be significant is also studied. The effect of ignoring cluster levels in a four-level CRT, which is often the case in the absence of an appropriate four-level model, is studied in details. Lastly, the proposed model is illustrated via a real-life human immunodeficiency virus prevention study conducted in the Bahamas.