Class: Mailchimp::Goal

Inherits:
Object
  • Object
show all
Defined in:
lib/mailchimp/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Goal

Returns a new instance of Goal.



2367
2368
2369
# File 'lib/mailchimp/api.rb', line 2367

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



2365
2366
2367
# File 'lib/mailchimp/api.rb', line 2365

def master
  @master
end

Instance Method Details

#events(list_id, email, start = 0, limit = 25) ⇒ Hash

Retrieve goal event data for a particular list member. Note: only unique events are returned. If a user triggers a particular event multiple times, you will still only receive one entry for that event.

Parameters:

  • list_id (String)

    the list id to connect to. Get by calling lists/list()

  • email (Hash)

    a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.

    • String

      email an email address

    • String

      euid the unique id for an email address (not list related) - the email “id” returned from listMemberInfo, Webhooks, Campaigns, etc.

    • String

      leid the list email id (previously called web_id) for a list-member-info type call. this doesn’t change when the email address changes

  • start (Int) (defaults to: 0)

    optional - control paging of lists, start results at this list #, defaults to 1st page of data (page 0)

  • limit (Int) (defaults to: 25)

    optional - control paging of lists, number of lists to return with each call, defaults to 25 (max=100)

Returns:

  • (Hash)

    Event data and metadata

    • Array

      data An array of goal data structs for the specified list member in the following format

      - [String] event The URL or name of the event that was triggered
      - [String] last_visited_at A timestamp in the format 'YYYY-MM-DD HH:MM:SS' that represents the last time this event was seen.
      
    • Int

      total The total number of events that match your criteria.



2384
2385
2386
2387
# File 'lib/mailchimp/api.rb', line 2384

def events(list_id, email, start=0, limit=25)
    _params = {:list_id => list_id, :email => email, :start => start, :limit => limit}
    return @master.call 'goal/events', _params
end

#record_event(list_id, email, campaign_id, event) ⇒ Hash

This allows programmatically trigger goal event collection without the use of front-end code.

Parameters:

  • list_id (String)

    the list id to connect to. Get by calling lists/list()

  • email (Hash)

    a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.

    • String

      email an email address

    • String

      euid the unique id for an email address (not list related) - the email “id” returned from listMemberInfo, Webhooks, Campaigns, etc.

    • String

      leid the list email id (previously called web_id) for a list-member-info type call. this doesn’t change when the email address changes

  • campaign_id (String)

    the campaign id to get content for (can be gathered using campaigns/list())

  • event (String)

    The name of the event or the URL visited

Returns:

  • (Hash)

    Event data for the submitted event

    • String

      event The URL or name of the event that was triggered

    • String

      last_visited_at A timestamp in the format ‘YYYY-MM-DD HH:MM:SS’ that represents the last time this event was seen.



2400
2401
2402
2403
# File 'lib/mailchimp/api.rb', line 2400

def record_event(list_id, email, campaign_id, event)
    _params = {:list_id => list_id, :email => email, :campaign_id => campaign_id, :event => event}
    return @master.call 'goal/record-event', _params
end