Class: Spree::Integrations::YahooAds

Inherits:
Spree::Integration
  • Object
show all
Defined in:
app/models/spree/integrations/yahoo_ads.rb

Overview

Yahoo!広告のコンバージョン計測(JSタグ方式)を Store 単位で有効化する Integration。

  • サイトジェネラルタグ(head) … yclid をファーストパーティ Cookie(_ycl_yjad)に捕捉
  • コンバージョン測定タグ(完了時) … 検索広告(YSS) / ディスプレイ広告(YDA)

検索広告(YSS)とディスプレイ広告(YDA)はタグの type / パラメータ名が異なる。 それぞれ独立して設定でき、両方設定した場合は完了時に2種類のコンバージョンを発火する。

  • YSS: yss_conversion / yahoo_conversion_id / yahoo_conversion_label
  • YDA: ydn_conversion / yahoo_ydn_conv_io / yahoo_ydn_conv_label

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.icon_pathObject



35
36
37
# File 'app/models/spree/integrations/yahoo_ads.rb', line 35

def self.icon_path
  'integration_icons/yahoo-ads-logo.png'
end

.integration_groupObject



31
32
33
# File 'app/models/spree/integrations/yahoo_ads.rb', line 31

def self.integration_group
  'analytics'
end

.integration_nameObject



27
28
29
# File 'app/models/spree/integrations/yahoo_ads.rb', line 27

def self.integration_name
  Spree.t('admin.integrations.yahoo_ads.name', default: 'Yahoo Ads')
end

Instance Method Details

#conversion_tags(value: nil) ⇒ Object

設定済みの広告種別ごとに、コンバージョン測定タグ(ytag)の { type:, config: } を返す。 YSS のみ→1件、YDA のみ→1件、両方→2件、未設定→空配列。value には注文金額を渡す。



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/spree/integrations/yahoo_ads.rb', line 49

def conversion_tags(value: nil)
  tags = []

  if yss_configured?
    tags << {
      type: 'yss_conversion',
      config: {
        'yahoo_conversion_id'    => preferred_yss_conversion_id,
        'yahoo_conversion_label' => preferred_yss_conversion_label,
        'yahoo_conversion_value' => value.to_s
      }
    }
  end

  if yda_configured?
    tags << {
      type: 'ydn_conversion',
      config: {
        'yahoo_ydn_conv_io'    => preferred_yda_conversion_id,
        'yahoo_ydn_conv_label' => preferred_yda_conversion_label,
        'yahoo_ydn_conv_value' => value.to_s
      }
    }
  end

  tags
end

#yda_configured?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/models/spree/integrations/yahoo_ads.rb', line 43

def yda_configured?
  preferred_yda_conversion_id.present? && preferred_yda_conversion_label.present?
end

#yss_configured?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/models/spree/integrations/yahoo_ads.rb', line 39

def yss_configured?
  preferred_yss_conversion_id.present? && preferred_yss_conversion_label.present?
end