Deducing vanishing of a cohomology class from pairings Let $M$ be an oriented closed manifold and $G$ a group. Let $x$ be a class in $H^*(M;\mathbb{Q})$.
Suppose that for every class $y\in H^*(BG,\mathbb{Q})$ and every continuous map
$$f\colon M\to BG,$$
we have that
$$\langle x\cup f^*y,[M]\rangle=0,$$
where $[M]$ is the fundamental class in $H_*(M,\mathbb{Q})$.
Question: Does it follow that $x=0$?
Comment: I guess it doesn't really matter whether we are working over the rationals or some other ring, or whether $M$ is a manifold, but this is the situation I'm looking at so I've included these details.
 A: If $\dim M = n$ and $x$ is a non-zero element of $H^{n-k}(M; \mathbb{Q})$, then you can produce a counterexample if you choose $G$ such that $H^k(BG; \mathbb{Q}) = 0$. For example, you could take $G$ to be finite. Another class of counterexamples can be formed by taking $k = 1$ and $G$ any connected topological group, or $k = 2$ and $G$ any simply connected topological group, or $k = 3$ and $G$ any simply connected Lie group.
There are also counterexamples when $H^k(BG; \mathbb{Q}) \neq 0$.
Let $M = \mathbb{HP}^2$ and let $x$ be a non-zero element of $H^4(M; \mathbb{Q}) \cong \mathbb{Q}$. For $G = S^1$, we have $BG = \mathbb{CP}^{\infty}$. As $\dim M = 8$, the only way we can have $\langle x\cup f^*y, [M]\rangle \neq 0$ is if $y \in H^4(\mathbb{CP}^{\infty}; \mathbb{Q})$. Note that $H^*(\mathbb{CP}^{\infty}; \mathbb{Q}) = \mathbb{Q}[\alpha]$ where $\alpha$ has degree two, so $y = k\alpha^2$ for some $k \in \mathbb{Q}$. Now note that for any map $f : M \to BS^1$, we have $f^*y = f^*(k\alpha^2) = k(f^*\alpha)^2 = 0$ so $\langle x\cup f^*y, [M]\rangle = 0$.
In fact, since $\mathbb{CP}^{\infty}$ is a $K(\mathbb{Z}, 2)$, we have $[M, \mathbb{CP}^{\infty}] \cong H^2(M; \mathbb{Z}) = 0$, so every map $f : M \to BS^1$ is nullhomotopic and hence $\langle x\cup f^*y, [M]\rangle = 0$ regardless of what $x$ is.
