Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Coding for marketers

581 visualizaciones

Publicado el

A brief tour of JavaScript, Python (and a bit of Regex) and some examples of how they can make our lives easier as marketers.

Publicado en: Marketing
  • Sé el primero en comentar

Coding for marketers

  1. 1. Coding for Marketers @robinlord8
  2. 2. If we handle what robots can't do
  3. 3. We can take advantage of what they do well
  4. 4. One idea to make your life easier
  5. 5. First steps to put that into practice
  6. 6. BIG Repeated Tasks Analytics Hell
  7. 7. BIG Repeated Tasks Analytics Hell
  8. 8. Policy Breach Notice Dear Customer, Some of your webpages include users' personally identifiable information (PII) in the URL. As a result, users' PII is accessible to any third-party with a tracking tag on these pages. We have further identified that these pages contain Google tagging products (such as AdWords conversion tracking, remarketing, DoubleClick for Publishers, Floodlight and Google Analytics).
  9. 9. https://www.distilled.net/resources/how-to-keep-personally-identifiable-information-out-of-google-analytics/
  10. 10. Tools Regular expressions - find me this thing Regex - find me this thing
  11. 11. Tools Regular expressions - find me this thing Regex Find me this thing
  12. 12. some words and some numbers: 1234
  13. 13. some words and some numbers: 1234 some
  14. 14. some words and some numbers: 1234 [a-zA-Z]+
  15. 15. some words and some numbers: 1234 d+
  16. 16. Tools Coding language, runs in browser - do this thing JavaScript Do this thing
  17. 17. https://websitesetup.org/javascript-cheat-sheet/ https://htmlcheatsheet.com/js/
  18. 18. var newTitle = document.title.replace(emailRegex, 'PII'); document.title = newTitle
  19. 19. var newTitle = document.title.replace(emailRegex, 'PII');
  20. 20. var newTitle = document.title.replace(emailRegex, 'PII'); A name - whatever I want
  21. 21. var newTitle = document.title.replace(emailRegex, 'PII'); The titleThe web page
  22. 22. var newTitle = document.title.replace(emailRegex, 'PII'); with thisReplace this
  23. 23. document.title = Amazon.co.uk: archie.lord@test.com newTitle = Amazon.co.uk: PII
  24. 24. document.title = newTitle
  25. 25. document.title = newTitle What we made
  26. 26. document.title = newTitle The titleThe web page
  27. 27. document.title = Amazon.co.uk: PII newTitle = Amazon.co.uk: PII
  28. 28. BIG Repeated Tasks Analytics Hell
  29. 29. BIG Repeated Tasks JavaScript and RegEx
  30. 30. BIG Repeated Tasks JavaScript and RegEx
  31. 31. 1 month later - new data Scheduled work
  32. 32. 1 month later - new data Shifting sands
  33. 33. Us using Excel Our problems
  34. 34. Tools Jupyter turns thisJupyter turns this
  35. 35. Tools Into thisInto this
  36. 36. Tools Regular expressions - find me this thing Regex - find me this thing
  37. 37. Code Coding language - versatile and relatively friendly, good for data processing Python - friendly, good with data
  38. 38. URL User Agent Status Hits https://surgery.biz/ Mozilla 200 1,000,003 Logfiles – an example of big repeated analysis
  39. 39. Import https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html
  40. 40. Resource https://realpython.com/python-first-steps/
  41. 41. log_data = pandas.read_csv('robin/logs.csv') https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html
  42. 42. log_data = pandas.read_csv('robin/logs.csv') https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html Whatever name I want
  43. 43. log_data = pandas.read_csv('robin/logs.csv') https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html Open csv file
  44. 44. log_data = pandas.read_csv('robin/logs.csv') https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html csv file location
  45. 45. log_data = pandas.read_csv('logsFinal05.csv') https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html This changes
  46. 46. log_data = pandas.read_csv('logsFinal10.csv') https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html This changes
  47. 47. log_data = pandas.read_csv('logsFinal10.csv') https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html This stays the same
  48. 48. Repeatability
  49. 49. Testing for numbers
  50. 50. URL Status Hits https://surgery.biz/ 200 1,000,003 https://surgery.biz/ 200 500,005 http://surgery.biz/ 301 300,000
  51. 51. URL Status Hits Active https://surgery.biz/ 200 1,000,003 True https://surgery.biz/ 200 500,005 True http://surgery.biz/ 301 300,000 False
  52. 52. URL Status Hits Active https://surgery.biz/ 200 1,000,003 True https://surgery.biz/ 200 500,005 True http://surgery.biz/ 301 300,000 False log_data['Active'] = log_data['Status']==200
  53. 53. URL Status Hits Active https://surgery.biz/ 200 1,000,003 True https://surgery.biz/ 200 500,005 True http://surgery.biz/ 301 300,000 False log_data['Active'] = log_data['Status']==200 Our data we named
  54. 54. URL Status Hits Active https://surgery.biz/ 200 1,000,003 True https://surgery.biz/ 200 500,005 True http://surgery.biz/ 301 300,000 False log_data['Active'] = log_data['Status']==200 Column we're filling
  55. 55. URL Status Hits Active https://surgery.biz/ 200 1,000,003 True https://surgery.biz/ 200 500,005 True http://surgery.biz/ 301 300,000 False log_data['Active'] = log_data['Status']==200 Our data
  56. 56. URL Status Hits Active https://surgery.biz/ 200 1,000,003 True https://surgery.biz/ 200 500,005 True http://surgery.biz/ 301 300,000 False log_data['Active'] = log_data['Status']==200 Column we're checking
  57. 57. URL Status Hits Active https://surgery.biz/ 200 1,000,003 True https://surgery.biz/ 200 500,005 True http://surgery.biz/ 301 300,000 False log_data['Active'] = log_data['Status']==200 Our check
  58. 58. URL Status Hits High Hits https://surgery.biz/ 200 1,000,003 True https://surgery.biz/ 200 500,005 True http://surgery.biz/ 301 300,000 False log_data['High Hits'] = log_data['Hits']>500000
  59. 59. URL Status Hits High Hits https://surgery.biz/ 200 1,000,003 True https://surgery.biz/ 200 500,005 True http://surgery.biz/ 301 300,000 False log_data['High Hits'] = log_data['Hits']>500000 Column we're filling
  60. 60. URL Status Hits High Hits https://surgery.biz/ 200 1,000,003 True https://surgery.biz/ 200 500,005 True http://surgery.biz/ 301 300,000 False log_data['High Hits'] = log_data['Hits']>500000 Column we're checking
  61. 61. URL Status Hits High Hits https://surgery.biz/ 200 1,000,003 True https://surgery.biz/ 200 500,005 True http://surgery.biz/ 301 300,000 False log_data['High Hits'] = log_data['Hits']>500000 Our check
  62. 62. Testing for words
  63. 63. URL Status Hits Http https://surgery.biz/ 200 1,000,003 False https://surgery.biz/ 200 500,005 False http://surgery.biz/ 301 300,000 True
  64. 64. URL Status Hits Http https://surgery.biz/ 200 1,000,003 False https://surgery.biz/ 200 500,005 False http://surgery.biz/ 301 300,000 True
  65. 65. URL Status Hits Http https://surgery.biz/ 200 1,000,003 False https://surgery.biz/ 200 500,005 False http://surgery.biz/ 301 300,000 True log_data['Http'] = log_data['URL'].str.contains('http:')
  66. 66. URL Status Hits Http https://surgery.biz/ 200 1,000,003 False https://surgery.biz/ 200 500,005 False http://surgery.biz/ 301 300,000 True log_data['Http'] = log_data['URL'].str.contains('http:') Column we're filling
  67. 67. URL Status Hits Http https://surgery.biz/ 200 1,000,003 False https://surgery.biz/ 200 500,005 False http://surgery.biz/ 301 300,000 True log_data['Http'] = log_data['URL'].str.contains('http:') Column we're checking
  68. 68. URL Status Hits Http https://surgery.biz/ 200 1,000,003 False https://surgery.biz/ 200 500,005 False http://surgery.biz/ 301 300,000 True log_data['Http'] = log_data['URL'].str.contains('http:') Our check
  69. 69. URL Active 301 High Hits Http https://surgery.biz/ True False True False https://surgery.biz/ True False True False http://surgery.biz/ False True False True
  70. 70. Eeeeeeeverything
  71. 71. Eeeeeeeverything
  72. 72. Eeeeeeeverything
  73. 73. Eeeeeeeverything Our output
  74. 74. Eeeeeeeverything Our output
  75. 75. Eeeeeeeverything Our output
  76. 76. Eeeeeeeverything Our output
  77. 77. Repeatability
  78. 78. For loop
  79. 79. checklist=['plastic', 'legal', 'dress', 'sue'] for item in checklist:
  80. 80. checklist=['plastic', 'legal', 'dress', 'sue'] for item in checklist: log_data[item] = log_data['URLs'].str.contains(item)
  81. 81. checklist=['plastic', 'legal', 'dress', 'sue'] for item in checklist: log_data[item] = log_data['URLs'].str.contains(item)
  82. 82. checklist=['plastic', 'legal', 'dress', 'sue'] for item in checklist: log_data['plastic']=log_data['URLs'].str.contains('plastic') URL plastic http://…sue-us False
  83. 83. checklist=['plastic', 'legal', 'dress', 'sue'] for item in checklist: log_data['legal'] = log_data['URLs'].str.contains('legal') URL plastic legal http://…sue-us False False
  84. 84. checklist=['plastic', 'legal', 'dress', 'sue'] for item in checklist: log_data['dress'] = log_data['URLs'].str.contains('dress') URL plastic legal dress http://…sue-us False False False
  85. 85. checklist=['plastic', 'legal', 'dress', 'sue'] for item in checklist: log_data[ ] = log_data['URLs'].str.contains( ) URL plastic legal dress sue http://…sue-us False False False True
  86. 86. checklist=['plastic', 'legal', 'dress', 'sue']
  87. 87. checklist=['plastic', 'legal', 'dress', 'sue', 'dresses', 'sale', 'product', 'free-trial', 'best-medical-decision-of-my-life', 'dr-nick']
  88. 88. checklist=['plastic', 'legal', 'dress', 'sue', 'dresses', 'sale', 'product', 'free-trial', 'best-medical-decision-of-my-life', 'dr-nick', 'many', 'more', 'checks', 'its', 'so', 'easy']
  89. 89. checklist=['plastic', 'legal', 'dress', 'sue', 'dresses', 'sale', 'product', 'free-trial', 'best-medical-decision-of-my-life', 'dr-nick', 'many', 'more', 'checks', 'its', 'so', 'easy', 'to', 'do', 'and', 'you', 'just', 'update', 'and', 'run', 'your', 'list', 'whenever', 'you', 'want', 'no', 'kidding', 'there', 'is', 'time', 'to', 'mess', 'around', 'with', 'stuff', 'like', 'this', 'because', 'we', 'aren't', 'repeating', 'work', 'in', 'excel']
  90. 90. for item in checklist: log_data[item] = log_data['URLs'].str.contains(item) H('contact',A2)),'contact',IF(ISNUMBER(SEARCH('dresses',A2)),'dresses',IF(ISNU MBER(SEARCH('sale',A2)),'sale',IF(ISNUMBER(SEARCH('product',A2)),'product', IF(ISNUMBER(SEARCH('free-trial',A2)),'free-trial',IF(ISNUMBER(SEARCH('best- medical-decision-of-my-life',A2)),'best-medical-decision-of-my- life',IF(ISNUMBER(SEARCH('dr-nick',A2)),'dr- nick',IF(ISNUMBER(SEARCH('many',A2)),'many',IF(ISNUMBER(SEARCH('more', A2)),'more',IF(ISNUMBER(SEARCH('checks',A2)),'checks',IF(ISNUMBER(SEARC H('its',A2)),'its',IF(ISNUMBER(SEARCH('so',A2)),'so',IF(ISNUMBER(SEARCH('eas y',A2)),'easy',IF(ISNUMBER(SEARCH('to',A2)),'to',IF(ISNUMBER(SEARCH('do',A 2)),'do',IF(ISNUMBER(SEARCH('and',A2)),'and',IF(ISNUMBER(SEARCH('you',A2) ),'you',IF(ISNUMBER(SEARCH('just',A2)),'just',IF(ISNUMBER(SEARCH('update',A 2)),'update',IF(ISNUMBER(SEARCH('and',A2)),'and',IF(ISNUMBER(SEARCH('run' ,A2)),'run',IF(ISNUMBER(SEARCH('your',A2)),'your',IF(ISNUMBER(SEARCH('list', A2)),'list',IF(ISNUMBER(SEARCH('whenever',A2)),'whenever',IF(ISNUMBER(SEA RCH('you',A2)),'you',IF(ISNUMBER(SEARCH('want',A2)),'want',IF(ISNUMBER(SE ARCH('no',A2)),'no',IF(ISNUMBER(SEARCH('kidding',A2)),'kidding',IF(ISNUMBE R(SEARCH('there',A2)),'there',IF(ISNUMBER(SEARCH('is',A2)),'is',IF(ISNUMBER( SEARCH('time',A2)),'time',IF(ISNUMBER(SEARCH('to',A2)),'to',IF(ISNUMBER(SE ARCH('mess',A2)),'mess',IF(ISNUMBER(SEARCH('around',A2)),'around',IF(ISNU MBER(SEARCH('with',A2)),'with',IF(ISNUMBER(SEARCH('stuff',A2)),'stuff',IF(ISN UMBER(SEARCH('like',A2)),'like',IF(ISNUMBER(SEARCH('this',A2)),'this',IF(ISNU MBER(SEARCH('because',A2)),'because',IF(ISNUMBER(SEARCH('we',A2)),'we',IF (ISNUMBER(SEARCH('aren't',A2)),'aren't',IF(ISNUMBER(SEARCH('repeating',A2 )),'repeating',IF(ISNUMBER(SEARCH('work',A2)),'work',IF(ISNUMBER(SEARCH( 'in',A2)),'in',IF(ISNUMBER(SEARCH('excel',A2)),'excel','other'))))))))))))))))))))))))) )))))))))))))))))))))))
  91. 91. Eeeeeeeverything Our output
  92. 92. Eeeeeeeverything Our output
  93. 93. Repeatability
  94. 94. BIG Repeated Tasks JavaScript and RegEx
  95. 95. Python JavaScript and RegEx
  96. 96. Some first steps
  97. 97. Specific
  98. 98. 1 month later - new data
  99. 99. General General
  100. 100. It's boring
  101. 101. It's boring Mindless Repetitive Fiddly Time consuming
  102. 102. Code is good at Accuracy Speed Comfort with data Focus Transparency
  103. 103. Code is good at Accuracy Speed Comfort with data Focus Transparency We need to handle: Conclusions Communication Direction
  104. 104. Plan your approach:
  105. 105. Choose your tools
  106. 106. Thinking time and sense checks
  107. 107. Structure
  108. 108. @robinlord8
  109. 109. Credits
  110. 110. Credits by slide number 26 – Iron Giant, 1992, Warner Bros, Pictures 45 – Sherlock, 2010-2018, Hartswood Films, BBC Wales, WGBH 75 – Final Space, 2018, Conaco
  111. 111. Resources
  112. 112. Resources 1. Regex101 - https://regex101.com/ 2. Google Tag Manager (a way to run JavaScript, will need to be added to your site, like Google Analytics) - https://www.google.com/analytics/tag-manager/ 3. Simo Ahava blog - https://www.simoahava.com/ 4. Sam's GTM PII fix blog post - https://www.distilled.net/resources/how-to-keep-personally-identifiable-information-out-of-google-analytics/ 5. JavaScript cheat sheets - https://websitesetup.org/javascript-cheat-sheet/, https://htmlcheatsheet.com/js/ 6. Anaconda - download everything you need to start with Python - including Jupyter - https://www.anaconda.com/download/ 7. Pandas documentation - https://pandas.pydata.org/pandas-docs/stable/ 8. Python beginner resource - https://realpython.com/python-first-steps/ 9. Stack Overflow (if you Google your problem, this will probably come up anyway) - https://stackoverflow.com/

×