# CID Marketing Source Code Assignment
Documentation on source code structure and the step by step logic on how marketing source codes are created and assigned.
# Source Code Structure
# Source Codes
The structure of source codes is as follows:
${category}|${channel}|${name}|${searchTerm}|${additionalKey}|${date}
Any value that's not present is omitted but the separators are kept. Note that CIDs is a source code without the category and the first delimiter, ${category}|.
For BBCRM the values are separated and are mapped to columns with the following names:
Msource1|Msource2|Msource3|Msource4|Msource5|Msource6.
# Subsource Codes
The structure of subsource codes is as follows:
${mcid}|${vanityUrlParam}|${additionalValue1}|${additionalValue2}|${additionalValue3}|${additionalValue4}
For BBCRM the values are separated and are mapped to columns with the following names:
MCID|VURL|Outbound Department|Sub Source 4|Sub Source 5|Sub Source 6.
# Source Code Assignment
When a user comes to the site the following list of events happens in analytics script library:
# 1. Capture URL Parameters
# On Web App Pages
On web app pages, if the cid URL parameter is detected in the URL, the web app will redirect the user to a page without the parameter. This is endemic to the web app's JavaScript library, it needs to be tied to a URL in order for it to work correctly. In these cases, the code will read the value of all URL parameters, including cid, set them into a cookie. After the page redirects, the code will move all URL parameter from a cookie into the data layer, specifically into digitalData.page.params property.
The web app pages are sponsorship (opens new window) and supporter center.
# On All Pages
On all pages, before the source codes are computed the script will read all URL parameters and set them into the data layer location digitalData.page.params.
# 2. Compute & Set Source Code
For marketing source codes, the script will first check if the cookie with a name
stc-analytics-sourceexists. If such cookie exists, the value in the cookie will be used as a source code value.If the cookie is not present, then the script then checks if the URL parameter
cidwas detected in data layer, specifically indigitalData.page.params.cidlocation. If value is detected it will be stored for source code creation.If the cookie is not present and the value is not present in the data layer's params property, the script then checks if the
cidparameter is present in the URL. If the value is in the URL, the value is stored for source code creation. It's strictly not necessary but a secondary check in casecidparameter is added dynamically to the URL. Document of channel to category mapping. Code that computes the mapping (opens new window).If all previous criteria are not met, the source code value will be computed based on the referrer.
If after steps 4 the code sees that we have a value of cid, then it will be converted into a source code by assigning a mapped category and formatting the date string.
Once we have a valid source code, it is written into a cookie with a name
stc-analytics-source. The cookie expires at the end of the user's session.On Luminate transaction forms the value of the source code is added into the form data.
When data is exported from Luminate to BBCRM, the source code data is separated out by the delimited pipe character
|and each value is imported separately into BBCRM (to be confirmed).
# Source Codes for Referrers
Default source code category is Web.
Default source code channel is Direct.
Default source code date is 12/31/1099 or today's date for channels Direct, Referral, Organic Search.
The script looks at the JavaScript referrer and assign source code partial values based on those domain. The values are computed based on the know domains for search engines, social media, and internal domains. Document of domain to channel & category mapping. Code that computes the values (opens new window).
# 3. Set Subsource Code
The subsource code relies solely on Adobe to provide us with the value of Marketing Cloud Id or MCID.
- The script checks if the id is available by trying to call the following code
window._satellite.getVisitorId().getMarketingCloudVisitorID(). If the code is not available the script will wait and check for this value after 500ms, the attempt will be made 10 times, after that the script will give up so there are no performance issues. - If we have the MCID, the code will check for a vanity URL parameter in the data layer. If the parameter exists, it will be appended to the subsource after a pipe delimiter
|. - The code also appends 4 more pipe delimiters, there were created for the future in case we decide to store any other values in the subsource.
- The value of the subsource is written into the cookie with a name
stc-analytics-sub_source. - On Luminate transaction forms the value of the subsource code is added into the form data.
- When data is exported from Luminate to BBCRM, the subsource code data is separated out by the delimited pipe character
|and each value is imported separately into BBCRM (to be confirmed).