Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Grab Google Analytics Visitor ID
- function getClientId() {
- // If ga is defined, check for the clientId and return it
- if (typeof ga !== 'undefined' && typeof ga.getAll === 'function') {
- var clientId = ga.getAll()[0].get('clientId');
- return clientId;
- // otherwise, return false so waitFor knows to try again within the time threshold
- } else {
- return false;
- }
- }
- // Number to be replaced on the left, with the Invoca Campaign ID mapping on the right.
- var numbersToReplace = {
- "877-727-2559" : "AllianceSecurity",
- "877-727-ALLY" : "AllianceSecurity",
- "1-877-727-2559" : "AllianceSecurity",
- "877-746-2559" : "AllianceSecurity",
- "1 (877) 746-2559" : "AllianceSecurity",
- "1-877-746-2559" : "AllianceSecurity"
- };
- // Define medium and source by referring domain
- var mediumSource = Invoca.Tools.parseReferrer({
- // Domain : [medium, source]
- "google.com" : ["organic", "google.com"],
- "bing.com" : ["organic", "bing.com"],
- "yahoo.com" : ["organic", "yahoo.com"],
- "" : ["direct", "direct"]
- }, ["referral", Invoca.Tools.trueDomain(document.referrer).slice(1)], null, "topLevelDomain");
- // Defines Last Paid Touch Attribution by reseting entry method when "gclid", "utm_source", or "utm_medium" detected in URL
- if (Invoca.Tools.readUrl("gclid") || Invoca.Tools.readUrl("utm_source") || Invoca.Tools.readUrl("utm_medium")){
- Invoca.Tools.resetAllData(); // Reset Attribution Information
- }
- // Tracks Google Paid Search
- if (Invoca.Tools.readUrl("gclid")){
- mediumSource = ["paid search", "google.com"]; // Attribute medium and source to reflect Google Paid Search
- }
- // Identify & Attribute the utm_medium Media Channel. Pick second item in array for medium
- var utmMedium = Invoca.Tools.readInvocaData("utm_medium", Invoca.Tools.readUrl("utm_medium")) || mediumSource[0];
- // Identify & Attribute the utm_source Media Source. Pick first item in array for source
- var utmSource = Invoca.Tools.readInvocaData("utm_source", Invoca.Tools.readUrl("utm_source")) || mediumSource[1];
- // Define Pool Params Hash
- var invocaParams = {
- utm_source: utmSource,
- utm_medium: utmMedium
- };
- // Invoca Number Replacing Function
- Invoca.PNAPI.integration({
- networkId: 1421, // Unique ID for your account, do not change
- numberToReplace: numbersToReplace, // Number to Campaign Association
- poolParams: invocaParams, // Grab Ringpool Parameters
- cookieDays: 30, // Set attribution window for users who visit your landing page
- numberSelector: "promoNumber",
- waitForData: [
- { on: getClientId, paramName: "g_cid" }
- ]
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement