{
    "componentChunkName": "component---src-templates-post-js",
    "path": "/random-number-convertkit-liquid",
    "result": {"data":{"site":{"siteMetadata":{"title":"your friend Joel's digital garden","description":"Articles and notes from a collaborator at egghead.io. Musings on software, business, and life from a skilled virtual assistant.","author":{"name":"Joel Hooks"},"keywords":["Video Blogger"]}},"mdx":{"excerpt":"If you want to generate a (pseudo) random number using a Liquid filter in  Convertkit , here's the code: What's actually going on here? This is a complex liquid template, so let's break it down, starting from the right and working our way…","fields":{"github":"https://github.com/joelhooks/joelhooks-com/tree/master/content/blog/2021-03-09--using-a-random-number-to-segment-emails-in-convertkit-aitomations-using-liquid~~KktIJ0DWd/index.mdx"},"body":"var _excluded = [\"components\"];\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"id\": \"KktIJ0DWd\",\n  \"slug\": \"random-number-convertkit-liquid\",\n  \"date\": \"2021-03-09T00:00:00.000Z\",\n  \"title\": \"Using a Random Number to Segment Emails in ConvertKit Automations using Liquid\",\n  \"published\": false\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, _excluded);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"If you want to generate a (pseudo) random number using a Liquid filter in \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://convertkit.com?lmref=ia534A\"\n  }, \"Convertkit\"), \", here's the code:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\"\n  }, \"{{ 'now' | date: \\\"%s\\\" | times: 1103515245 | plus: 12345 | divided_by: 65536 | modulo: 32768 | modulo: 100 }}\\n\")), mdx(\"h2\", null, \"What's actually going on here?\"), mdx(\"p\", null, \"This is a complex liquid template, so let's break it down, starting from the right and working our way left.\"), mdx(\"h3\", null, \"using modulo in liquid\"), mdx(\"p\", null, \"The \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://en.wikipedia.org/wiki/Modulo_operation\"\n  }, \"modulo\"), \" of a number is the remainder of a math operation.\"), mdx(\"p\", null, \"The \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"modulo: 100\"), \" affects the range. Using \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"100\"), \" will give you a result \", mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"between\"), \" 0-100. If you wanted a number between 0-10, use 10.\"), mdx(\"h3\", null, \"Liquid Math\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"times\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"plus\"), \", and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"divided_by\"), \" are fairly straight forward mathematics for multiplication, addition, and division respectively. The actual values of these numbers is frankly a bit of arcane \\\"magical\\\" number fuckery, that I don't personally understand, which is to say I just googled it.\"), mdx(\"p\", null, \"If you are very curious about WHY this works, this sequence of numbers is \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://rosettacode.org/wiki/Linear_congruential_generator\"\n  }, \"linear congruential generator\"), \" that produces a pseudo-random number \\uD83E\\uDD14\"), mdx(\"h3\", null, \"Using the date as a seed\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"'now' | date: \\\"%s\\\"\"), \" is parsed by liquid as the current seconds of \\\"now\\\", which is the \\\"seed\\\" for our random number generator where the seconds are the actual seconds between now and 1970 often referred to as \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://en.wikipedia.org/wiki/Unix_time\"\n  }, \"\\\"epoch\\\" or UNIX time\"), \".\"), mdx(\"h2\", null, \"Using the random number in Convertkit Automations\"), mdx(\"p\", null, \"My specific use case for this was sending automations to a fraction of a group for testing because \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://convertkit.com?lmref=ia534A\"\n  }, \"ConvertKit\"), \" automation do not have a built in way to accomplish this.\"), mdx(\"p\", null, \"Here's the basic automation:\"), mdx(\"p\", null, mdx(\"span\", {\n    parentName: \"p\",\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"1035px\"\n    }\n  }, \"\\n      \", mdx(\"a\", {\n    parentName: \"span\",\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/844e9b8841bc7f7a92877c520294887f/da952/random-segment-using-liquid-in-convertkit.png\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"132.43243243243242%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAaCAYAAAC3g3x9AAAACXBIWXMAABYlAAAWJQFJUiTwAAACXklEQVRIx6VVy27TQBT1b8MOFvAF7NggsUBiQytIKGkKkdomNIBoswgS0CaO8rLj18x4ZmwnOWgmdhKbtHUg0pFvZu49vm8bp63vqNZO8ebtCQ7efcRh5ROqtTPUG23UGxc78eGkiaPjcxzVFZqo1M5QPT7H5y8dGACQJAkWiwXm8zkWywX+5bdMn4ZHBfxQwmcbqDOX8BQhXBHDDeVKVmeUw8tBpOAwCI8QhDIHdbY+FzFofwgydbS8fb+BsotAuYRRJMsM1FPICBGA6OUrRM02YgCM53VW8opQPY3i27aVZZzo/E76JpyphcVyCSYkAib2I9TgEXwawgsohpaN6cyFTxl8xndEVIIwR87ECoW7Yg7vDTk7o6nR7Tp3EBYNFCyPwQn4/3vIRKSb9fX7S7Q7Ay3/TVaSUDW4qiqlBOZghP5giCSOIeO5HoRShMWQGBcglGI0HmNq2Qg5BwnF2rhUDrdJVYuo1pnYDmzXR6D+b/dgGQ+zambEKo9EjV9a7d2FuZMwMxJrL/IkQmNDVHL0/B2zrYsRRmA8Wd/vVZR8aBJqVbYGXRx0T/UCJLlFUaIPtRyu3q62DCUUXfM3Ln51QAOCUMitipckzPKoCHumid5NH5PRBNc3PfiEbumW9TCVuYzhOC56fRM9cwDLtiGieL+Q86FzuK4Hx/Uwc10tE7XK+J4hU9WDIta5VA0+83y4AcXYsuERtn/ITsAw8wlmPtXzTdKKU5EU9O9ZX5l3z56/wMPHT/Hg0RNU6g3IOfT4BeGes5wpX/34ida3K7S+XuJ6MAKTya0fNeX9HxatxM4y/JtPAAAAAElFTkSuQmCC')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  }), \"\\n  \", mdx(\"img\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-image\",\n    \"alt\": \"random number segement automation in convertkit\",\n    \"title\": \"random number segement automation in convertkit\",\n    \"src\": \"/static/844e9b8841bc7f7a92877c520294887f/e3189/random-segment-using-liquid-in-convertkit.png\",\n    \"srcSet\": [\"/static/844e9b8841bc7f7a92877c520294887f/a2ead/random-segment-using-liquid-in-convertkit.png 259w\", \"/static/844e9b8841bc7f7a92877c520294887f/6b9fd/random-segment-using-liquid-in-convertkit.png 518w\", \"/static/844e9b8841bc7f7a92877c520294887f/e3189/random-segment-using-liquid-in-convertkit.png 1035w\", \"/static/844e9b8841bc7f7a92877c520294887f/44d59/random-segment-using-liquid-in-convertkit.png 1553w\", \"/static/844e9b8841bc7f7a92877c520294887f/da952/random-segment-using-liquid-in-convertkit.png 1872w\"],\n    \"sizes\": \"(max-width: 1035px) 100vw, 1035px\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    },\n    \"loading\": \"lazy\",\n    \"decoding\": \"async\"\n  }), \"\\n  \"), \"\\n    \")), mdx(\"ol\", null, mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"The automation is triggered.\"), mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"We check to see if the custom property as a value, in this example it is \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"demo_segment\")), mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"If it isn't set, we add a value to \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"demo_segment\"), \" using our liquid template\\nas the field value.\")), mdx(\"p\", null, \"Now your subscriber will have a value between 0-100 that you can use to segment them.\"), mdx(\"p\", null, mdx(\"span\", {\n    parentName: \"p\",\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"1035px\"\n    }\n  }, \"\\n      \", mdx(\"a\", {\n    parentName: \"span\",\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/747717930c54e728249f3c2bab5658eb/aa991/split-on-conditional-automation-convertkit.jpg\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"117.37451737451737%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAXABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAd2CUEoAf//EABYQAQEBAAAAAAAAAAAAAAAAAAEQIP/aAAgBAQABBQLSDf/EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8BH//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8BH//EABYQAAMAAAAAAAAAAAAAAAAAABAgIf/aAAgBAQAGPwJqf//EABkQAQADAQEAAAAAAAAAAAAAAAEAEBExIf/aAAgBAQABPyGO6Vzr5AygcAl//9oADAMBAAIAAwAAABA8MMP/xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAEDAQE/EB//xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAECAQE/EB//xAAcEAEAAgIDAQAAAAAAAAAAAAABABEQMSFBYXH/2gAIAQEAAT8QgSGjC7UepyPW8d56pIfKJZP/2Q==')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  }), \"\\n  \", mdx(\"img\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-image\",\n    \"alt\": \"split on conditional in a convertkit automation\",\n    \"title\": \"split on conditional in a convertkit automation\",\n    \"src\": \"/static/747717930c54e728249f3c2bab5658eb/af659/split-on-conditional-automation-convertkit.jpg\",\n    \"srcSet\": [\"/static/747717930c54e728249f3c2bab5658eb/8356d/split-on-conditional-automation-convertkit.jpg 259w\", \"/static/747717930c54e728249f3c2bab5658eb/bc760/split-on-conditional-automation-convertkit.jpg 518w\", \"/static/747717930c54e728249f3c2bab5658eb/af659/split-on-conditional-automation-convertkit.jpg 1035w\", \"/static/747717930c54e728249f3c2bab5658eb/51eb8/split-on-conditional-automation-convertkit.jpg 1553w\", \"/static/747717930c54e728249f3c2bab5658eb/aa991/split-on-conditional-automation-convertkit.jpg 1850w\"],\n    \"sizes\": \"(max-width: 1035px) 100vw, 1035px\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    },\n    \"loading\": \"lazy\",\n    \"decoding\": \"async\"\n  }), \"\\n  \"), \"\\n    \")), mdx(\"p\", null, \"For me, I am sending a sequence to a small percentage to verify some functionality during a pre-sale and we've learned from past experience (\\uD83D\\uDE05) that it's smart to send to a small group before blasting thousands of people with potentially broken links or functionality.\"), mdx(\"p\", null, \"I'll start with 2%, then up that to 8%, 10%, 20%, 50%, 80%, 100% just reflowing subscribers through the automation as needed since we are guaranteed in \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://convertkit.com?lmref=ia534A\"\n  }, \"Convertkit\"), \" that any given email won't be sent twice if it's in a Sequence.\"), mdx(\"p\", null, \"Works great!\"), mdx(\"p\", null, \"You may also like this post that discusses \", mdx(\"strong\", {\n    parentName: \"p\"\n  }, mdx(\"a\", {\n    parentName: \"strong\",\n    \"href\": \"https://joelhooks.com/self-paced-email-course-convertkit\"\n  }, \"using ConvertKit automation to create self-paced email courses for evergreen product pitches\")), \".\"));\n}\n;\nMDXContent.isMDXComponent = true;","frontmatter":{"title":"Using a Random Number to Segment Emails in ConvertKit Automations using Liquid","date":"March 09, 2021","banner":null,"slug":"random-number-convertkit-liquid","keywords":null}}},"pageContext":{"id":"02611702-40fa-5b7d-a03e-774f4d2c3f19","prev":{"id":"b77ac617-766f-53f5-b7fa-b70a8fad9720","parent":{"name":"index","sourceInstanceName":"blog"},"excerpt":"The Video.js docs have a good explaination for using Video.js with React, but it focuses on a class based implementation. Getting Video.js to consistently work with React Hooks is fairly straight forward, with a gotcha or two. Here's the hook: The…","fields":{"title":"useVideoJs: a React Hooks for Video.js","slug":"usevideojs-a-react-hooks-for-videojs","date":"2021-03-26T00:00:00.000Z"}},"next":{"id":"c40958ff-ffc8-568d-916b-02b2214fdde1","parent":{"name":"index","sourceInstanceName":"blog"},"excerpt":"Tools like  Convertkit  provide a lot of powerful tools you can use for marketing automation, but as a developer I want to goa layer deeper and find that using serverless functions with a framework like Next.js provides immense power to customize…","fields":{"title":"Serverless Marketing Automation with Convertkit and Next.js","slug":"serverless-marketing-automation","date":"2021-02-17T00:00:00.000Z"}}}},
    "staticQueryHashes": ["1045846374"]}