A more microscopic view of the cross section is

\displaystyle  \frac{dN}{dS} \sigma \rho dt dS= dn,

where N is number of incident particle, \sigma is the total cross section, \rho is the particle density in the target, S is the area, t is the thickness of the target, and n is particle detected.

The cross section is a constant, so, after integration,

\displaystyle \sigma = \frac{n}{N \rho t} .

If the beam is not uniform, dN/dS = f(S) is a function of S. The integration has to be careful.