ruby

Choose Language

Urls Calls

/urls/list.json

Get the 100 most clicked URLs

Example Call

begin mandrill = Mandrill::API.new 'YOUR_API_KEY' result = mandrill.urls.list # [{"unique_clicks"=>42, # "sent"=>42, # "url"=>"http://example.com/example-page", # "clicks"=>42}] rescue Mandrill::Error => e # Mandrill errors are thrown as exceptions puts "A mandrill error occurred: #{e.class} - #{e.message}" # A mandrill error occurred: Mandrill::InvalidKeyError - Invalid API key raise end
Parameters
No parameters
Return Value
array the 100 most clicked URLs and their stats
return[] struct the individual URL stats
url string the URL to be tracked
sent integer the number of emails that contained the URL
clicks integer the number of times the URL has been clicked from a tracked email
unique_clicks integer the number of unique emails that have generated clicks for this URL
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.

/urls/time-series.json

Return the recent history (hourly stats for the last 30 days) for a url

Example Call

begin mandrill = Mandrill::API.new 'YOUR_API_KEY' url = "http://example.com/example-page" result = mandrill.urls.time_series url # [{"unique_clicks"=>42, # "sent"=>42, # "clicks"=>42, # "time"=>"2013-01-01 15:00:00"}] rescue Mandrill::Error => e # Mandrill errors are thrown as exceptions puts "A mandrill error occurred: #{e.class} - #{e.message}" # A mandrill error occurred: Mandrill::InvalidKeyError - Invalid API key raise end
Parameters
url* string an existing URL
Return Value
array the array of history information
return[] struct the information for a single hour
time string the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
sent integer the number of emails that were sent with the URL during the hour
clicks integer the number of times the URL was clicked during the hour
unique_clicks integer the number of unique clicks generated for emails sent with this URL during the hour
Errors
Unknown_Url The requested URL has not been seen in a tracked link
Invalid_Key The provided API key is not a valid Mandrill API key
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.

/urls/tracking-domains.json

Get the list of tracking domains set up for this account

Example Call

begin mandrill = Mandrill::API.new 'YOUR_API_KEY' result = mandrill.urls.tracking_domains # [{"last_tested_at"=>"2013-01-01 15:40:42", # "created_at"=>"2013-01-01 15:30:27", # "cname"=> # {"error"=>"example error", # "valid"=>true, # "valid_after"=>"2013-01-01 15:45:23"}, # "valid_tracking"=>true, # "domain"=>"example.com"}] rescue Mandrill::Error => e # Mandrill errors are thrown as exceptions puts "A mandrill error occurred: #{e.class} - #{e.message}" # A mandrill error occurred: Mandrill::InvalidKeyError - Invalid API key raise end
Parameters
No parameters
Return Value
array the tracking domains and their status
return[] struct the individual tracking domain
domain string the tracking domain name
created_at string the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
cname struct details about the domain's CNAME record
valid boolean whether the domain's CNAME record is valid for use with Mandrill
valid_after string when the domain's CNAME record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
error string an error describing the CNAME record, or null if the record is correct
valid_tracking boolean whether this domain can be used as a tracking domain for email.
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.

/urls/add-tracking-domain.json

Add a tracking domain to your account

Example Call

begin mandrill = Mandrill::API.new 'YOUR_API_KEY' domain = "track.example.com" result = mandrill.urls.add_tracking_domain domain # {"created_at"=>"2013-01-01 15:30:27", # "domain"=>"example.com", # "valid_tracking"=>true, # "last_tested_at"=>"2013-01-01 15:40:42", # "cname"=> # {"valid_after"=>"2013-01-01 15:45:23", # "error"=>"example error", # "valid"=>true}} rescue Mandrill::Error => e # Mandrill errors are thrown as exceptions puts "A mandrill error occurred: #{e.class} - #{e.message}" # A mandrill error occurred: Mandrill::InvalidKeyError - Invalid API key raise end
Parameters
domain* string a domain name
Return Value
struct information about the domain
domain string the tracking domain name
created_at string the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
cname struct details about the domain's CNAME record
valid boolean whether the domain's CNAME record is valid for use with Mandrill
valid_after string when the domain's CNAME record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
error string an error describing the CNAME record, or null if the record is correct
valid_tracking boolean whether this domain can be used as a tracking domain for email.
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.

/urls/check-tracking-domain.json

Checks the CNAME settings for a tracking domain. The domain must have been added already with the add-tracking-domain call

Example Call

begin mandrill = Mandrill::API.new 'YOUR_API_KEY' domain = "track.example.com" result = mandrill.urls.check_tracking_domain domain # {"domain"=>"example.com", # "cname"=> # {"valid_after"=>"2013-01-01 15:45:23", # "error"=>"example error", # "valid"=>true}, # "last_tested_at"=>"2013-01-01 15:40:42", # "created_at"=>"2013-01-01 15:30:27", # "valid_tracking"=>true} rescue Mandrill::Error => e # Mandrill errors are thrown as exceptions puts "A mandrill error occurred: #{e.class} - #{e.message}" # A mandrill error occurred: Mandrill::UnknownTrackingDomainError - No tracking domain exists with that name raise end
Parameters
domain* string an existing tracking domain name
Return Value
struct information about the tracking domain
domain string the tracking domain name
created_at string the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
cname struct details about the domain's CNAME record
valid boolean whether the domain's CNAME record is valid for use with Mandrill
valid_after string when the domain's CNAME record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
error string an error describing the CNAME record, or null if the record is correct
valid_tracking boolean whether this domain can be used as a tracking domain for email.
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
Unknown_TrackingDomain The provided tracking domain does not exist.
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.