Trace operators on modules This question is motivated by this other one.
A classical result of linear algebra states what follows

Up to scalar, trace is the only linear operator $\text{M}(n,k) \stackrel{t}{\to} k $ such that $t(AB) = t(BA)$.

So there are two natural generalization of the problem. The first one is in the direction of replacing $k$ with a ring $A$. The other is to ignore the restriction to finite dimensional vector spaces.

Consider a finitely generated module $M$ on a commutative unital ring $A$.
End($M$) has a natural module structure.

A trace operator is a morphism of modules End($ M) \stackrel{tr}{\to} A$ such that $tr(fg)=tr(gf)$.

Tr, the set of trace operators is a submodule of $\text{Hom}_A(\text{End(M)}, A)$. In the special case of vector spaces, its dimension is $1$.

What happens for general rings? Can we recover a partial result? How many trace operators are there?
What should be the trace for a morphism on modules? Sum of eigenvalues looks to me naive.

Examples

*

*In the case of $M = \mathbb{Z}_6, A = \mathbb{Z}$. There are no trace operators.

Attempts

*

*In the case of vector spaces the submodule genetated by $fg-gf$ has codimension 1. What's its codimension in the case of free modules? Maybe this question makes much more sense when $A$ is a PID.

 A: As always Michael Shulman has good answers. In here he generalizes and broadens the meaning behind a trace operator saying it is a fixed point operator: it counts fixed points.
Just to give an idea the trace operator have meaning for a dualizable object in a monoidal category. The dualizable objects $X$ are those for which $(-)\otimes X$ has a left and right adjoint.
At page 8 he says without proof that the dualizable objects of $R$-Mod are the finitely generated projective modules, and as such the only modules over which a trace operator can be defined. This explains a posteriori why the example $\mathbb{Z}_6$ does not work.
As such the trace of any endomorphism on a finitely generated projective module becomes as expected the sum of the diagonal of any matrix representing it.
Edit(writing in the night):
Why it is well defined?
In the general world depicted by Shulman the trace of an endomoprhism $f:P\to P$ where $P$ is a projective finitely generated module, is defined as follows:
$$I\to P\otimes P^\star\stackrel{f\otimes id_P}{\longrightarrow}P\otimes P^\star\stackrel{\sim}{\longrightarrow}P^\star\otimes P\stackrel{ev}{\longrightarrow} I,$$ where $I=R$ is the unity of the tensor product.
This definition seem a little bit abstract and not comprehensible. The requirement of $P$ being dualizable comes into play right here: an equivalent characterization of a dualizable object is for the canonical map 
$$P\otimes P^\star\to\hom(P,P)$$ to be an isomorphism.
From this we can rewrite the definition to get a more pleasant one:
$$I\stackrel{\varphi}{\to} \hom(P,P)\stackrel{\hom(P,f)}{\longrightarrow}\hom(P,P)\stackrel{\sim}{\longrightarrow}P^\star\otimes P\stackrel{ev}{\longrightarrow} I,$$
where $\hom(P,f)$ is the usual postcomposition and $\varphi(1)=Id_P$. From this definition it is clear that given an endomorphism $f\in\hom(P,P)$ we can write it as an element of $P\times P^\star$, $f=\sum_{i=1}^n v_i\otimes w^\star_i$, and the trace will be $Tr(f)=\sum_{i=1}^n w^\star_i(v_i)$, independent of the representation chosen.
For one last thing I found this paper, in which Rohrl finds a universal property for the trace and here Beckwith expands it and explains it. I don't like and understand it well so what I say next may not be correct. He seems to have found a generalization of the trace but I am not 100% sure because of the lack of examples and because when he considers the case of modules he looks at what happens on finitely generated prjective. From what I understood the trace becomes a morphism $t:End_R(M)\to T$ with a universal property among those morphisms $t'$ such that for all $\mu\in End(M)$ and for all $\alpha\in Aut(M)$ we have $t'(\mu)=t'(\alpha\mu\alpha^{-1})$, so we have a morphism $\beta:T\to T'$ making the following diagram commutative:
\begin{array}{ccc}
End(M)&\stackrel{t}{\to} & T\\
    &\searrow &\downarrow\\
    & & T'.
\end{array} 
A: Let $R$ be a commutative ring, which could be $\mathbb Z$. The $R$-module $A/[A,A]$ that is the quotient of $A$ by the subgroup generated by all elements of the for $ab-ba$ with $a$ and $b$ in $A$ is the $0$th Hochschild homology $HH_0(A/R)$ of the $R$-algebra, and simultaneously the $0$th cyclic homology $HC_0(A/R)$ of that $R$-algebra. The set of $R$-linear traces on the $A$ is the same thing as $\hom_R(A/[A,A],R)$, so describing traces is more or less the same thing as describing either $HH_0(A/R)$ or $HC_0(A/R)$. (Clearly $HH_0$ and $HC_0$ do not really depend on $R$, only on $A$, but the higher degree versions do: that is why I am insisting on the $R$ throughout)
$\def\End{\operatorname{End}}$You are asking about traces on the $R$-algebra $A=\End_B(M)$, for some $R$-algebra $B$ and some $B$-module $M$, and thus, indirectly about Hochschild/cyclic homology of $\End_B(M)$. Literally entire books have been written about that :-)
A simple example is the following. If the $B$-module $M$ is a progenerator, that is, a finitely generated projective generator, then the $R$-algebras $B$ and $\End_B(M)$ are $R$-linearly Morita equivalent, and an important theorem then tells us that their whole Hochschild/cyclic homologies are isomorphic. In particular, this tells you that in that case $HH_0(\End_B(M))$ and $HH_0(B)$ are isomorphic $R$ modules, so that $\End_B(M)$ and $B$ have the «same» traces.
If $B$ is a field, for example, then every finite-dimensional $B$-vector space $M$ is a progenerator, and this tells us that there is an isomorphism between the traces on $\End_B(M)$ and those on $B$. But on $B$ there is only one up to scalars, so there is only one on $\End_B(M)$. This is the result you mentioned in the question.
More generally, for any algebra $B$ a free $B$-module of finite rank is a progenerator, and this gives the generalization to these modules that other answers mention.
A: The case $M = A^n$ behaves more like vector spaces. Maybe one should focus on that one.  If $A$ is a domain one can tensor by quotients $\mathbb{Q}(A)$ of $A$ $$\text{End(M)} \subset \text{End}(M) \otimes_A \mathbb{Q}(A)  $$ if one can extend the operator to the whole module, then the answer is close... because of linearity it's enough to define $\bar{tr}$ on $E_{ij} \otimes \frac{a}{b} $. We put $$\bar{tr}(E_{ij} \otimes \frac{a}{b}) =  tr(E_{ij}) \otimes \frac{a}{b}   $$
One can see this map as the map $tr \otimes \text{id}$, obtainted by functoriality of tensor product.
This extends the operator to a linear operator $$\text{End}(M) \otimes_A \mathbb{Q}(A) \stackrel{\bar{tr}}{\to} A \otimes_A \mathbb{Q}(A) =  \mathbb{Q}(A) $$ 
Is $\bar{tr}$ a trace operator? We can prove it again on generators. 
$$\bar{tr} (E_{ij} \otimes \frac{a}{b} \circ E_{hk} \otimes \frac{c}{d})   = \bar{tr} (E_{ij} \circ E_{hk} \otimes \frac{ac}{bd}) = tr(E_{hk} \circ E_{ij}) \otimes \frac{ac}{bd} = \bar{tr} (E_{hk} \otimes \frac{c}{d} \circ E_{ji} \otimes \frac{a}{b} ).$$
Thus we can apply the classification of trace operator on vector spaces.

If $M = A^n, A$ domain, a trace operator is a normalization of the sum of elements on the diagonal of the matrix.

We strongly used the hypotesis that to tensor is not going to kill anything. So Ann$(m)$ shoud be $0$ for any element to make this proof work.
In the case $M = \mathbb{Z}_6$ we have $\text{End(M)} \not\subset \text{End}(M) \otimes_A \mathbb{Q}(A).  $

Update.
