Given a topological group, say $G$, it is well known that the classifying space $BG$ classifies $G$ principal bundles. Under some mild assumption on $G$, one model of $BG$ is the geometric realization of the nerve of the one object groupoid $G⇉*$.

Let $P\to M$ be a $G$ principal bundle. We can form the action groupoid $P\rtimes G=\{P\times G⇉ P\}$, whose nerve is also the bar construction. There are natural groupoid morphisms $P\rtimes G\to G⇉*$, and $P\rtimes G\to \underline{M}$, where $\underline{M}$ is the trivial groupoid.

Taking the nerve and then taking geometric realization, we obtain a map

$$|N_\bullet (P\rtimes G)|\to BG.$$

Notice that $N_\bullet (P\rtimes G)\to N_\bullet \underline{M}$ is acyclic, thus we have a map
$$M\to BG$$
up to homotopy. 

My question is that: whether this map is the classifying map for the $G$-principal bundle $P\to M$? 

Thanks a lot.