<<xAct`xPert`

$PrePrint=ScreenDollarIndices;

DefManifold[M,4,{a,b,c,d,e,f}]

DefMetric[-1,g[-a,-b],CD,{";","D"},WeightedWithBasis->AIndex]

DefTensor[A[-a,-b],M,Antisymmetric[{-a,-b}]]

epsilong[a,b,c,g]Detg[]

WeightOf[%]

DefTensor[B[-a,-b],M]

trial=epsilong[-a,-b,-c,-d]A[a,b]B[c,d]

VarD[g[e,f],CD][trial]

trial2=epsilong[a,b,c,d]A[-a,-b]B[-c,-d]Sqrt[-Detg[]]

VarD[g[e,f],PD][%]