DIL Tools
Describes methods in the DIL.tools
namespace. These utility functions help you perform specific tasks.
getSearchReferrer
Returns search terms used to reach the current page.
Purpose of getSearchReferrer
In DIL, getSearchReferrer
returns search results (names and key words) used to reach your site. You can pass in specific search terms to this function or let it search the supported search engines ( AOL, Ask, Bing, Google, and Yahoo) against document.referrer
by default.
Function signature
Function signature: DIL.tools.getSearchReferrer(uri, initConfig)
Function Parameters
getSearchReferrer
accepts:
{string}
: (Optional) A string containing the search URL (usesdocument.referrer
if undefined).{object}
: (Optional) An object containing the configuration for thehostPattern
,queryParam
, orqueryPattern
.
And returns:
{object}
An object that contains valid names and keywords.
Examples
var results = DIL.tools.getSearchReferrer();
var results = DIL.tools.getSearchReferrer("https://www.ehow.com/search.aspx?q=adobe+rules");
var results = DIL.tools.getSearchReferrer("https://www.ehow.com/ search.aspx?q=adobe+rules",{ hostPattern:/ehow\./, queryParam:"p" });
var results = DIL.tools.getSearchReferrer("https://www.ehow.com/search.aspx?q=adobe+rules, { hostPattern:/ehow\./, search_pattern:/[&\?]p=([^&]+/ });
decomposeURI
Disassembles a Uniform Resource Identifier ( URI) into its constituent components: hash
, host
, href
, pathname
, protocol
, search
, and uriParams
.
Function signature: DIL.tools.decomposeURI
Function Parameters
decomposeURI
accepts:
uri {string}
: (Optional) A string containing the URI. Defaults todocument.location.href
if not specified.
And returns:
{object}
: An object that contains valid names and keywords.
Sample Code
var uriData = DIL.tools.decomposeURI('https://www.adobe.com/?arg1=123&arg2=456#am');
{
hash : "#am",
host : "www.adobe.com",
hostname : "www.adobe.com",
href : "https://www.adobe.com/?arg1=123&arg2=456#am",
pathname : "",
protocol : "https:",
search : "?arg1=123&arg2=456",
uriParams : {
arg1 : "123",
arg2 : "456"
}
}
getMetaTags
Searches for specific content defined in the meta tags on a Web page and returns that data in an object.
Function signature
Function signature: DIL.tools.getMetaTags( 1 or more parameters)
Function Parameters
getMetaTags
accepts one or more name parameters (string type) to search for. It returns an object composed of key-value pairs.
Sample Code
var dataLib = DIL.create({
partner: 'partnerName',
containerNSID: containerNSID
});
dataLib.api.signals(DIL.tools.getMetaTags('application', 'keywords', 'description'), 'c_').submit();
var dataLib = DIL.create({
partner: `partnerName',
containerNSID: containerNSID
});
dataLib.api.signals(DIL.tools.getMetaTags('application','keywords', 'description'), 'c_').submit();