I'm working on a project, which only has a handful (~10) of different creatives, which I've setup as DFP Tags with blocks. It seems that the way the module currently works, that in order to configure proper targeting with tokens, that I'd have to either:

  1. Create and manage multiple DFP tags, just to include the right tokens per Drupal entity (This is not ideal from a maintenance and bloat perspective. If I only need 10 different tags, I'd rather not maintain 30-60+ tag instances and their placement, just to get proper targeting params.)
  2. Create a custom module and alter each block to handle the targeting there (This is an option, but it's also a maintenance issue because there is an admin UI exposed, and doing this in code will disconnect from that UI.)
  3. Create a more flexible UI to apply global targeting parameters (Hence, this issue.)

I think that D8 Pathauto module improvements are fantastic, and its Patterns UI is perfect for the use case of applying global targeting parameters here. Here's a screenshot of that UI:

Screenshot of Pathauto Patterns UI

In place of the "Pattern" column, we could simply include a list (possibly trimmed) of targeting params and values.

Thoughts?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jacine created an issue. See original summary.

Jacine’s picture

Issue summary: View changes
dawehner’s picture

Assigned: Unassigned » dawehner

I'm going to give it a try, and if its just to keep @jacine sort of sane.

dawehner’s picture

Here is some initial work, which just covers the UI so far.

dawehner’s picture

Status: Active » Needs review
FileSize
37.4 KB

Its not really pathauto but it still uses the condition api.

Status: Needs review » Needs work

The last submitted patch, 5: 2768625-5.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
39.59 KB
2.89 KB

This is too fast. I cannot handle that.

alexpott’s picture

Status: Needs review » Needs work
  1. I really like the idea and the execution looks great too.
  2. If the listing page could have some of the additional details of the pathauto page that'd be great.
  3. +++ b/src/Entity/TargetingInterface.php
    @@ -0,0 +1,44 @@
    +  /**
    +   * @return \Drupal\Core\Condition\ConditionPluginCollection
    +   */
    +  public function getConditionCollection();
    +
    +  public function getConditionType();
    +
    +  public function getConditionConfig();
    +
    +  public function setConditionConfig($instance_id, array $configuration);
    

    Could do with docs.

  4. +++ b/src/Form/Targeting.php
    @@ -0,0 +1,238 @@
    +    $form['id'] = [
    +      '#type' => 'machine_name',
    +      '#maxlength' => 128,
    +      '#default_value' => $targeting->id(),
    +      '#description' => $this->t('A unique machine-readable name for this DFP targeting. Only use letters, numbers and underscores. Example: top_banner'),
    +      '#machine_name' => [
    +        'exists' => ['Drupal\dfp\Entity\Tag', 'load'],
    +      ],
    +    ];
    

    This is a targeting thing right - not a Tag? Also I think this is a bit weird to require the user to come up with the machine name and not allow them to get descriptive.

  5. +++ b/src/Form/Targeting.php
    @@ -0,0 +1,238 @@
    +  protected function buildConditionInterface(array $form, FormStateInterface $form_state) {
    

    Missing docs.

  6. +++ b/src/Form/Targeting.php
    @@ -0,0 +1,238 @@
    +  public static function onConditionTypeChange($form, FormStateInterface $form_state) {
    

    Docs

  7. +++ b/src/TargetingCalculator.php
    @@ -0,0 +1,114 @@
    +    $targeting_settings = $this->configFactory->get('dfp.settings')->get('targeting') ?: [];
    

    Should do this at the end - saves a query if not needed.

  8. +++ b/src/View/TagView.php
    @@ -85,22 +87,32 @@ class TagView {
    -  public function __construct(TagInterface $tag, ImmutableConfig $global_settings, TokenInterface $token, ModuleHandlerInterface $module_handler) {
    +  public function __construct(TagInterface $tag, ImmutableConfig $global_settings, array $targeting_settings, TokenInterface $token, ModuleHandlerInterface $module_handler) {
    

    I think it is a bit friendlier to anything that is customising this module to add this new param at the end.

dawehner’s picture

Thank you for your review alex!

I think it is a bit friendlier to anything that is customising this module to add this new param at the end.

Thank you

Jacine’s picture

Hi! Should I test this as is, or wait for changes?

dawehner’s picture

Status: Needs work » Needs review
FileSize
2.89 KB
39.59 KB

Damnit, I just forgot to upload a patch.

Jacine’s picture

Status: Needs review » Needs work
FileSize
118.37 KB

It works! Thank you so much. It's really nice to see this come together. I have some nitpicks, and some issues, that hopefully can be resolved easily.

Global settings

/admin/structure/dfp/settings
I think the "Global targeting" section that shows here should be moved to the "List Targeting" tab (which we should rename - see below). I think it could either be provided as a "global" targeting set provided by the DFP module by default, or even just printed at the top of this page.

List Targeting

/admin/structure/dfp_ads/targeting

  1. We need a better name for this screen. I think it should just be called "Targeting".
  2. We need more fields, and to display them in the table. Right now there is only a machine name. Ideally there would be a label, description and a machine name

Add DFP Targeting

/admin/structure/dfp_ads/targeting/add

  1. I was having JS issues with this page (which I don't see ATM), but I think it should really be 2-step (AJAX) process:
    1. Define the target "group" settings/conditions: Set a label, machine name, description, and conditions.
    2. Configure actual targeting: Enter actual targets and values, be able to browser Tokens available.
  2. The options for "Condition type" are off. The list is too complex and doesn't have something for taxonomy terms (which is why I suspect that part isn't working for me). Can we just use what Pathauto uses or was there some reason we're using something else (I blame myself)? See attached pic.
  3. The targeting options desperately need the token tree list link on the page, so it's possible to see what's there.

Let me know if I can explain this further, or if anything sounds crazy/weird?

Jacine’s picture

The options for "Condition type" are off. The list is too complex and doesn't have something for taxonomy terms (which is why I suspect that part isn't working for me). Can we just use what Pathauto uses or was there some reason we're using something else (I blame myself)? See attached pic.

I take this back upon discussing further. Using the standardized contextual filter is better. We'll just need to work in support for taxonomy terms.

dawehner’s picture

I think the "Global targeting" section that shows here should be moved to the "List Targeting" tab (which we should rename - see below). I think it could either be provided as a "global" targeting set provided by the DFP module by default, or even just printed at the top of this page.

Great idea! I would ask @alexpott here though, whether this belongs into this issue, or whether this cleanup should be done separately.

Jacine’s picture

Great idea! I would ask @alexpott here though, whether this belongs into this issue, or whether this cleanup should be done separately.

Up to you guys. As long as it all works, I guess it could be moved to follow-up.

Critical piece still missing here:

  1. The ability to configure targeting settings for taxonomy terms.

Major stuff:

  1. List of tokens that can be applied on page.
  2. Label, and description (in addition to machine name)

The rest could be considered minor.

dawehner’s picture

Working on it.

dawehner’s picture

Note: Actually we have an option for taxonomy terms: Its hidden behind "vocabulary", because well, this is what the condition is about. Its about the vocabularies of terms.

Changes of this patch:

  • Add label and description support
  • Some tries to fix some form errors, see comment in the patch
  • Show token info

see screenshot:

dawehner’s picture

Status: Needs work » Needs review

.

Status: Needs review » Needs work

The last submitted patch, 17: 2768625-17.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
42.56 KB
842 bytes

Here is a quick fix

Status: Needs review » Needs work

The last submitted patch, 20: 2768625-20.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
49.31 KB
11.45 KB

This patch now takes into account cacheability metadata.

dawehner’s picture

Status: Needs review » Needs work

The last submitted patch, 22: 2768625-22.patch, failed testing.

dawehner’s picture

Now targets could be defined in multiple places. They have to be merged to not be overridden on the ads site.

bleen’s picture

Status: Needs work » Needs review

here testbot

Status: Needs review » Needs work

The last submitted patch, 25: 2768625-25.patch, failed testing.