Follow

SmartGet

SmartGet can be used in Templates for Plain Text, HTML, and/or Mobile content.  You can also use Get Tags in Articles.

Using SmartGet

To get content from an external html or text page, do the following:

  1. Open a Template or Article for editing.
  2. In the content, define the tag using the correct syntax.
  3. Save the Template or Article.
  4. Preview the Template to see if the content displays.
  5. Send a test campaign to verify the content displays.

SmartGet Syntax

SmartGet is the universal command to get external content. The syntax for SmartGet is as follows:

%%smartget url="[URL]"&command=[COMMAND]%%

[URL]  only is enclosed in quotation marks, & between URL and each command. 

If the command is improperly formated, the URL cannot be found, or some other error occurs, the command will fail.  When the Get fails, the campaign will not send messages to subscribers, and a failure notification will be delivered to the address of the user who initiated the campaign. 

Commands

The [URL] is the URL to the content (html OR text) and [COMMAND] is one or more of the following options:

Command

Description

base_url

Uses the defined base URL in place of the default tracking URL.

Example: base_url=http:// sub.mydomain.com

default_value

Used in conjunction with must_contain, must_not_contain,  or the start_at/end_at commands, the Default Value displays alternate content when the expected content is not found.  The alternate text must be enclosed with double quotes.

Example: default_value="Alternate Text"

For example, consider the following SmartGet tag:

%%smartget url="http:// mydomain.com/mysubject.txt"&must_not_contain="Document Not Found"&default_value="Special offers for Today"%%

If the .txt page cannot be accessed and throws the defined error, then the alternative text "Special offers for Today" will appear in the subject line of the campaign.

Added in version 10.7.0.

fix_quotes

Fixes typesetter marks, such as "?" replacing special characters like curly quotes, from content defined by programs such as Word, with the correct or similar characters.  Defaults to 0, not enabled.

Example: fix_quotes=1 (enabled)

fix_relative

Fixes relative URLs in the content, adding protocol and host information to create absolute URLs.  Defaults to 0, not enabled.

Example: fix_relative=1 (enabled)

must_contain

Grabs the content if the page contains the specified text.  Otherwise, causes the campaign to fail.

Example: must_contain=[SOME%20TEXT]

After version 10.7.0, the command support spaces when the string is enclosed in double quotes, such as:

must_contain="SOME TEXT"

must_not_contain

Grabs the content if the page does not contain the specified text.  Otherwise, causes the campaign to fail.  Especially helpful to ensure the phrase "document not found" does not appear in the content.

Example: must_not_contain=[SOME%20TEXT]

After version 10.7.0, the command support spaces when the string is enclosed in double quotes, such as:

must_not_contain="SOME TEXT"

start_at / end_at

Grab only a specific section of content in a file.  Use the Start and End arguments to indicate where in the file to find the content to use.  The alternate text must be enclosed with double quotes.

For example, a page contains the following text:

My example text appears next.  Start text. Middle string of content. Text end. Don't show anything else after that.

If the SmartGet includes the following arguments: start_at="Start text."&end_at="Text end."

The message would display: "Start text. Middle string of content. Text end."

If either the Start and/or End strings are not found, the command fails and the message is not be sent unless a Default Value is defined to display alternate text. 

Example: start_at="Start text"&end_at="text end."&default_value="Alternate text"

The Start/End can be used in conjunction with Must/Must Not Contain, where the string appears or does not appear within the whole page.  It does not check within the specified portion only.

Example: start_at="Start text"&end_at="text end."&must_contain="Begin next"&default_value="Alternate text"

If the string "Begin next" appears anywhere on the page, then the portion between the Start and End arguments will be placed into the message.  If the string does not appear anywhere in the page, then the Default Value will display.

The Start/End arguments are case sensitive.  For example, if the string in the content is "Start here", then using start_at="start here" will fail.

Be aware that if the content between the Start and End contains HTML or XML content, it is possible to insert content into your template that contains mismatched tags, such as an open <b> with no end, or a close </td>.  Be certain to preview your template and determine if and issues are apparent before deploying the content.

Added in version 10.7.0.

As of version 10.12.0, the text defined in the Start and End arguments is not included in the displayed content.  In the example above, the message will now display: " Middle string of content. "

timeout

Stops attempting to pull the content if no response is received in the specified amount of time, defined in seconds. 

If a URL times out with cacheget, the system will automatically refresh the cache by going out and obtaining a new copy of the content.  If it does not time out, then content is pulled from an in-memory cache. 

Defaults to 300 seconds, or five minutes.

Example: timeout=[SECONDS]

wrap

Wraps the content at the specified character length.  Wrapping occurs on word boundaries and not within quoted text or JavaScript.  It most useful for paginating plain-text.  Defaults to 0, not enabled.

Example: wrap=[NUMBER] (enabled, wrap at every [NUMBER] characters)

url

REQUIRED - Specifies the URL to access.  The URL must be a valid, publicly available page that may easily be opened and examined in your web browser.  It can be text or HTML content, depending on the format of your template.

Example: url=http://mydomain.com/mytext.txt

Example: url="http://mydomain.com/mycode.html?get=1"

Examples

The following are examples using the commands above. All commands can be combined in any order:

%%smartget url="http://mydomain.com/myplaintext.txt"&base_url=http:// sub.mydomain.com&fix_quotes=1&fix_relative=1&must_contain=My%20Company%20Name&must_not_contain=document%20not%20found&timeout=120&wrap=90&default_value="No Content Found"%%

SmartGet must_contain:   

%%smartget url="http://mydomain.com/mypage.html"&must_contain=My%20Site%20Name%%

SmartGet must_not_contain:   

%%smartget url="http://mydomain.com/mypage.html"&must_not_contain="500%20Servlet%20Exception"%%

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk