• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.1 Passing customised targeting criteria into ad tags

akia

Well-known member
#1
I've been looking at the Google DFP Small Business documentation and I want to take advantage of the fact that I can target ads to whether my members are male or female, etc etc.

According to the documentation I've need to add the following to the page header:


Code:
<script language="JavaScript">
  GA_googleAddAttr("Sex", "$Variable");
</script>

But how to I get Xenforo to update the $Variable bit with whether the member is male/female/unspecified. Etc

Also if I was to add some custom field to the profile for hobbies ect, How would I add those as well.

Thanks
 

Fuhrmann

Well-known member
#3
Code:
<script language="JavaScript">
  GA_googleAddAttr("Sex", {$visitor.gender});
</script>
This will use 'male' or 'female'.
 

akia

Well-known member
#5
Well what I've done is added this to my template:
Code:
<xen:if hascontent="true">
<xen:contentcheck>
<xen:if is="{$visitor.gender}">
<script language="JavaScript">
  GA_googleAddAttr("Sex", "{$visitor.gender}");
</script>
</xen:if>
</xen:contentcheck>
</xen:if>
I'm not a programmer but it seems to work, so if there is no gender specified it hides the tag. if it helps anyone else.