XF 2.1 Passing Thread Tags to Google DFP

chris TFF


We pass a number of variables, such as thread ID and forum ID to our Google DFP installation to help target our adverts.

We would also like to pass Thread Tags and User Group IDs. We have tried a few code variations, but have't made them work. Both would be arrays.

We have managed to pass a specific Usergroup ID - but ideally we need to pass all of them.

Can anyone help with the right code please?

This is what we are using so far:

<xf:if is="{$forum.node_id}">
      <!-- Forum ID: {$forum.node_id} -->
            <xf:if is="{$threadID|raw}">
               <!-- THREAD ID: {$threadID|raw} -->
            <xf:if is="{{$xf.visitor.isMemberOf([43])}}">
                <!-- UG: Sugar Beet Grower-->

chris TFF

Working on this further ourselves - the value:


is not available in the header.

In the Thread_View template, we can set:

<xf:page option="threadTags" value="{$thread.tags}" />

This makes $threadTags available in the header.

But if you output $threadTags or $threadTags|raw at the header level is just passes the word "Array".

We need the ouput in this format in the header to pass the tags to Google DFP:

googletag.pubads().setTargeting('XFTAG', ['value1', 'value2', 'value3'])
basically need to build this: 'value1', 'value2', 'value3'

You can also loop though thread tags at the thread_view template level looking for particular tags and setting a value and that works to (but we have over 5000 tags in our dataset):

<xf:foreach loop="$thread.tags" value="$tag">
    <xf:if is="$tag.tag == 'blackgrass'">
        <xf:page option="threadTags" value="tagBlackgrass" />
    <xf:if is="$tag.tag == 'pixelexit'">
        <xf:page option="threadTags" value="tagPixelexit" />
    <xf:if is="$tag.tag == 'customtag'">
        <xf:page option="threadTags" value="tagCustomtag" />

But how do you build an array that will pass accross in the header?

@Chris D what are we missing
Last edited: