The cmCustomLinkClickHandler function
You can redefine the cmCustomLinkClickHandler function to include custom code that sends additional tags along with the link click tag that is automatically generated when visitors click HTML anchors. Your custom function code sends specific tags for specific anchors or groups of related anchors on a page, such as social media links or document download links.
To enable cmCustomLinkClickHandler, declare the following function anywhere in the page after the eluminate
tag library is included.
Note: The cmCustomLinkClickHandler works only for anchors that support automatic link click data collection. Additional tags are that are sent with cmCustomLinkClickHandler can incur server calls.
function cmCustomLinkClickHandler(e) {
// your custom code here
}
Example HTML and JavaScript Code sending element tags when a user clicks a social media anchor
<BODY>
<script type="text/javascript">
function cmCustomLinkClickHandler(e) {
if(e.rel == "external"){
var cm_socialLinkid = e.id;
cmCreateElementTag(cm_socialLinkid,"SOCIAL MEDIA");
}
}
</script>
<ul class="social-sharing">
<li class="social-sharing_icon facebook">
<a id="footer-facebook" rel="external" href="https://www.facebook.com/acoustic">Share:Facebook</a>
</li>
<li class="social-sharing_icon twitter">
<a id="footer-twitter" rel="external" href="//twitter.com/acoustic">Share:Twitter</a>
</li>
<li class="social-sharing_icon instagram">
<a id="footer-instagram" rel="external" href="//instagram.com/acoustic">Share:Instagram</a>
</li>
<li class="social-sharing_icon pinterest">
<a id="footer-pinterest" rel="external" href="//www.pinterest.com/acoustic/">Share:Pinterest</a>
</li>
</ul>
</BODY>
The cmSetClientID function
The cmSetClientID(...) function is required and sets values for Client ID, 1st Party method (Client Managed or Acoustic Managed (Acoustic Managed)), Data Collection Domain, and Cookie Domain. This function must be called on every page sending data to Acoustic Digital Analytics.
<head>
<script type="text/javascript" src="//libs.coremetrics.com/eluminate.js">
</script>
<script type="text/javascript">
// Client Managed First Party
cmSetClientID("99999999",true,"data.coremetrics.com","thesite.com");
// Acoustic Managed First Party
cmSetClientID("99999999",false,"<dcd>.thesite.com","thesite.com");
</script>
</head>
<body> ... <script type="text/javascript"> cmCreatePageviewTag("FAQ Page 1", "FAQ");
</script> </body>
Europe Data Centers - Data Collection Domains
The Europe Data Center uses the following production data collection domain:
// Client Managed First Party
cmSetClientID("99999999", true, "data.de.coremetrics.com", "thesite.com");
Sending Data Tag Requests to Multiple Client IDs
It is possible to copy data tags to two or more Client IDs by specifying a semicolon-delimited list of ID values. The IDs specified must all be production IDs or test IDs: a mix of test and production IDs is not allowed. If sending tags from multiple sites where each site also copies tags to a dedicated 'aggregate' ID, the first ID specified in the list should be the 'aggregate' ID. The 'aggregate' ID reports data tags copied from multiple sites.
- - Example of sending tag requests from site #1 to the 'aggregate' ID and site-specific ID #1, where 99999999 is the 'aggregate' ID and 11111111 is the site-specific ID:
cmSetClientID("99999999;11111111",true,"data.coremetrics.com","site1.com");
- ... and from site #2 to the 'aggregate' ID and site-specific ID #2 (ID 22222222):
cmSetClientID("99999999;22222222",true,"data.coremetrics.com", "site2.com");
Note that copying requests to two or more ID's increases total server calls assessed by (1*the number of IDs specified). In the example above, each tag sent from the page is copied to 2 IDs, resulting in 2x total server calls assessed.
Digital Analytics Account, Sales, and Provisioning teams is able to provide specific information regarding what IDs, if any, have been contracted for 'aggregate' data collection and the Monthly Million Server Call volume contracted for each ID.
Sending Data Tag Requests to Multisite Analytics ID and Site IDs
Data is sent to a Multisite Analytics 'Site ID' by using a pipe delimiter (|) in the Client ID parameter of cmSetClientID(...).
Note: Do not use these characters in <SiteID> values: ampersand (&), pipe (|), single quote ('), or comma (,)
- Example of sending tag requests to Multisite Analytics Client ID '88888888' and a Sub-ID, where <SiteID> is the configured Multisite Analytics Sub-ID:
cmSetClientID("88888888|<SiteID>",true,"data.coremetrics.com","site1.com");
- Example of sending tag requests to 1) a regular Client ID '99999999', 2) a Multisite Analytics Client ID '88888888' and 3) a Site ID, where <SiteID> is the configured Multisite Analytics Sub-ID:
cmSetClientID("99999999;88888888|<SiteID>",true,"data.coremetrics.com", "site1.com");
It is possible to copy tag requests to multiple Multisite SiteIDs.
cmSetClientID("59990000|SITEID-1;59990000|SITEID-2",true,"data.coremetrics.com",
"site1.com");
Tag requests sent from this page generate identical reporting for both SITEID-1 and SITEID-2. At the Global ID level, each tag is reported once for each SiteID it is copied to. For example, if a PageView
tag is sent, two total 'page views' are reported for that page
ID
in Global ID 59990000 reporting.
Note: Sending tags to more than one SiteID costs one server call per specified SiteID.
Parameter | Required | Description |
---|---|---|
Client ID | Required | Unique 8-digit Acoustic Digital Analytics-assigned account code associated with a single analytics data warehouse and reporting instance. |
Data Collection Method | Required | Boolean true or false: True indicates 'Client Managed' 1st Party. False indicates 'Acoustic Managed' 1st Party or '3rd Party' as applicable. |
Data Collection Domain | Required | The target domain for Acoustic Digital Analytics data collection requests.
If Data Collection Method = false: Data Collection Domain should be set to the Acoustic Managed 1st Party data collection domain. Example: ("<1stpartydcd>.thesite.com"). If Data Collection Method = true: Data Collection Domain should be set to "data.coremetrics.com". |
Cookie Domain | Required | The domain for Client Managed cookies.
Cookie Domain should be set to the 2nd level site domain ("thesite.com") of the domain serving the tagged page(s). In cases of extra domain levels prior to the uniquely identifying site domain value, this might be a 3rd or higher level. Example: "thesite.co.uk".
|
The cmSetupNormalization function
Use the optional cmSetupNormalization function to remove undesired session, visitor, or user (registrant) specific query string parameters from collected tag data. You can use this function to normalize automatically collected link click tag 'Target HREF/URL (hr)' values or to normalize page view tag 'Destination URL (ul)' and 'Referring URL (rf)' values.
cmSetupNormalization(blackListLinkClickquery-_-blackListPageViewURLquery,whiteListLinkClickquery-_-whiteListPageViewURLquery,myCustomNormalizeURL);
Following are the parameters for cmSetupNormalization:
Note: Null values are required for parameters you do not use.
Parameter | Description |
---|---|
blackListLinkClickquery | A comma-delimited list of query string parameter values to be removed from the collected link click tag 'Target HREF/URL (hr)' data. Use this parameter to implement normalization for link URLs. |
whiteListLinkClickquery | A comma-delimited list of query string parameter values to retain in collected link click tag 'Target HREF/URL (hr)' data. All other query string parameters are removed from the collected 'Target HREF?URL (hr)' data. Use this parameter to implement normalization for link URLs. |
blackListPageViewURLquery | A comma-delimited list of query string parameter values to be removed from the collected Page View tag 'Destination URL (ul)' and 'Referring URL (rf)' values. |
whiteListPageViewURLquery | A comma-delimited list of query string parameter values to be retained in collected Page View tag 'Destination URL (ul)' and 'Referring URL (rf)' values. All other query string parameters are removed from the collected 'Destination URL (ul)' and 'Referral URL (rf)' data. Example of blackListPageViewURLquery. |
myCustomNormalizeURL | This is a custom function that you define and call; in parameter 3 of cmSetupNormalization. The use of a custom normalization function disables the standard cmSetupNormalization parameters 1 and 2 (specify null for these parameters). The custom function must contain any code that is needed to perform link click and page view blacklist or whitelist query string parameter normalization. The purpose of this function is to enable removal of the undesired session, visitor, or user-based data from collected link click URL or Page View URL values, when such values are in a form other than standard query string parameters (?query= or &query=). |
Normalizing link URL values
When a system collects click data, the data is stored and reported for each unique URL value. If a single page or link URL value contains data, which varies by session, visitor, or user, that unique URL record can appear many times in reporting. Each affected URL record will usually have only one or a low number of clicks.
To avoid this error in reporting, you need to ensure that collected click metrics are aggregated. You can accomplish this task by using cmSetupNormalization to normalize the collected URL values, removing certain query string parameter values from the collected data.
Example of using blackListLinkClickquery
For the link:
<a href="/page1.html?jsessionid=12345678&val=abc&guid=x9876">page1.html?
jsessionid=12345678&val=abc&guid=x9876</a>
Use this tag:
cmSetupNormalization("jsessionid,guid",null,null);
Final collected Link Click 'Target HREF/URL (hr)' value:
"/page1.html?val=abc"
Example of whiteListLinkClickquery
For the link:
<a href="/page1.html?jsessionid=12345678&val=abc&guid=x9876">page1.html?
jsessionid=12345678&val=abc&guid=x9876</a>
Use this tag:
cmSetupNormalization(null,"val",null);
Final collected Link Click 'Target HREF/URL (hr)' value:
"/page1.html?val=abc"
Normalizing page URL values
Page View tags automatically collect Destination URL and Referring URL data. The collected Page View 'Page ID' value is determined by how the tags are implemented on a page. However, page view destination URL and referring URL values are automatically extracted from window.location.href and document.referrer by the eluminate tag library. While 'Page ID' is the primary entity for reporting of Page activity in Digital Analytics, you can improve the quality of reported URL values by using the cmSetupNormalization function to normalize the collected URL data, removing variable session, visitor, and user-related values.
Example of blackListPageViewURLquery
Destination URL: "/destinationurl/doc.html?jsessionid=12345678&val=abc&guid=x9876&product=1234"
Referring URL: "/referringurl/doc.html?jsessionid=87654321&val=xyz&guid=y6789"
Use this tag:
cmSetupNormalization("-_-jsessionid,guid",null,null);
Final collected Page View 'Destination URL' and 'Referring URL' values are:
"/destinationurl/doc.html?val=abc&product=1234"
"/referringurl/doc.html?val=xyz"
Example of whiteListPageViewURLquery
Destination URL: "/destinationurl/doc.html?jsessionid=12345678&val=abc&guid=x9876&product=1234
Referring URL: "/referringurl/doc.html?jsessionid=87654321&val=xyz&guid=y6789"
Use this tag:
cmSetupNormalization(null,"-_-val,product",null,null);
Final collected Page View 'Destination URL' and 'Referring URL' values are:
"/destinationurl/doc.html?val=abc&product=1234"
"/referringurl/doc.html?val=xyz"
Normalizing page and link URLs with the same function call
You can combine link click and page view blacklists or whitelists in the same cmSetupNormalization call. However, you cannot use blacklist and whitelist parameters on the same page.
Example of configuring both blackListLinkClickquery and blackListPageViewURLquery in the same page
This statement removes jsessionid=, guid=, and krypto= query string parameters from collected link click (hr) data, and remove jsessionid= and guid= query string parameters from collected Page View Destination URL (ul) and Referring URL (rf) data.
cmSetupNormalization("jsessionid,guid,krypto-_-jsessionid,guid",null,null);
Normalizing link URL that contains non-standard string values
You can also use cmSetupNormalization to remove undesired session, visitor, or user-based data from collected link click URL or Page View URL values when these values are in a form other than standard query string parameters (?query= or &query=).
Example myCustomNormalizeURL function definition
This function identifies link click tag Target/HREF URLs containing the value "userid." and removes an 18-character long value from the URL path.
function myCustomNormalizeURL(url, isHref) {
var newURL = url;
var pageURL=document.URL;
if (isHref) {
if (newURL.indexOf("userid.")>-1) {
var startParm=(newURL.indexOf("userid")+6);
var endParm=startParm+19;
newURL=newURL.substring(0,startParm)+newURL.substring(endParm);
}
}
return newURL;
}
cmSetupNormalization(null, null, myCustomNormalizeURL);
Example anchor link HREF/URL: "/path/userid.3e9gh3eff0h34da35f/path2/page.html"
Final collected link click tag 'Target HREF/URL (hr)' value: "/path/userid/path2/page.html"
Setting the cmSetupOther function
Use the optional cmSetupOther function to set optional implementation parameters. If this function is not called, default settings are used for the implementation.
Note: Acoustic Support might request that specific values be set to optimize data collection or identify and correct issues with data collection.
Example of using cmSetupOther
In this example, cmSetupOther makes the following changes:
- Change the default explore attribute parameter value delimiter to "_-_".
- Disable automatic generation of all on-site marketing tracking impression tags.
cmSetupOther({"cm_AttributeDelimiter":"_-_","cm_TrackImpressions":""});
Comments
0 comments
Article is closed for comments.