Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. // Grab Google Analytics Visitor ID
  2. function getClientId() {
  3.  
  4. // If ga is defined, check for the clientId and return it
  5. if (typeof ga !== 'undefined' && typeof ga.getAll === 'function') {
  6.  
  7. var clientId = ga.getAll()[0].get('clientId');
  8. return clientId;
  9.  
  10. // otherwise, return false so waitFor knows to try again within the time threshold
  11. } else {
  12. return false;
  13. }
  14. }
  15.  
  16. // Number to be replaced on the left, with the Invoca Campaign ID mapping on the right.
  17. var numbersToReplace = {
  18. "877-727-2559" : "AllianceSecurity",
  19. "877-727-ALLY" : "AllianceSecurity",
  20. "1-877-727-2559" : "AllianceSecurity",
  21. "877-746-2559" : "AllianceSecurity",
  22. "1 (877) 746-2559" : "AllianceSecurity",
  23. "1-877-746-2559" : "AllianceSecurity"
  24. };
  25.  
  26. // Define medium and source by referring domain
  27. var mediumSource = Invoca.Tools.parseReferrer({
  28. // Domain : [medium, source]
  29. "google.com" : ["organic", "google.com"],
  30. "bing.com" : ["organic", "bing.com"],
  31. "yahoo.com" : ["organic", "yahoo.com"],
  32. "" : ["direct", "direct"]
  33. }, ["referral", Invoca.Tools.trueDomain(document.referrer).slice(1)], null, "topLevelDomain");
  34.  
  35. // Defines Last Paid Touch Attribution by reseting entry method when "gclid", "utm_source", or "utm_medium" detected in URL
  36. if (Invoca.Tools.readUrl("gclid") || Invoca.Tools.readUrl("utm_source") || Invoca.Tools.readUrl("utm_medium")){
  37. Invoca.Tools.resetAllData(); // Reset Attribution Information
  38. }
  39.  
  40. // Tracks Google Paid Search
  41. if (Invoca.Tools.readUrl("gclid")){
  42. mediumSource = ["paid search", "google.com"]; // Attribute medium and source to reflect Google Paid Search
  43. }
  44.  
  45. // Identify & Attribute the utm_medium Media Channel. Pick second item in array for medium
  46. var utmMedium = Invoca.Tools.readInvocaData("utm_medium", Invoca.Tools.readUrl("utm_medium")) || mediumSource[0];
  47.  
  48. // Identify & Attribute the utm_source Media Source. Pick first item in array for source
  49. var utmSource = Invoca.Tools.readInvocaData("utm_source", Invoca.Tools.readUrl("utm_source")) || mediumSource[1];
  50.  
  51. // Define Pool Params Hash
  52. var invocaParams = {
  53. utm_source: utmSource,
  54. utm_medium: utmMedium
  55. };
  56.  
  57. // Invoca Number Replacing Function
  58. Invoca.PNAPI.integration({
  59. networkId: 1421, // Unique ID for your account, do not change
  60. numberToReplace: numbersToReplace, // Number to Campaign Association
  61. poolParams: invocaParams, // Grab Ringpool Parameters
  62. cookieDays: 30, // Set attribution window for users who visit your landing page
  63. numberSelector: "promoNumber",
  64. waitForData: [
  65. { on: getClientId, paramName: "g_cid" }
  66. ]
  67. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement