diff --git a/lib/utm_conversion.rb b/lib/utm_conversion.rb index 037db14..e4bc41b 100644 --- a/lib/utm_conversion.rb +++ b/lib/utm_conversion.rb @@ -13,7 +13,7 @@ module UTMConversion class Error < StandardError; end class << self - attr_accessor :storage_adapter + attr_accessor :storage_adapter, :store_utm_data_in_session, :store_utm_date_in_storage_adapter def configure yield self @@ -33,4 +33,6 @@ def record_conversion(session, event_data) end self.storage_adapter ||= UTMConversion::Storage::InMemory.new + self.store_utm_data_in_session = true + self.store_utm_date_in_storage_adapter = true end diff --git a/lib/utm_conversion/capture/utm_params_middleware.rb b/lib/utm_conversion/capture/utm_params_middleware.rb index d13df20..b317901 100644 --- a/lib/utm_conversion/capture/utm_params_middleware.rb +++ b/lib/utm_conversion/capture/utm_params_middleware.rb @@ -28,8 +28,8 @@ def extract_utm_params(request) def store_utm_data(session, utm_params) return if utm_params.nil? || utm_params == {} - UTMConversion::Session::UTMData.store(session, utm_params) - UTMConversion.storage_adapter.store(session.id, utm_params) + UTMConversion::Session::UTMData.store(session, utm_params) if UTMConversion.store_utm_data_in_session + UTMConversion.storage_adapter.store(session.id, utm_params) if UTMConversion.store_utm_date_in_storage_adapter end end end