{"id":7901,"date":"2025-10-07T15:12:22","date_gmt":"2025-10-07T15:12:22","guid":{"rendered":"https:\/\/ioninteractive.com\/ionacademy\/?p=7901"},"modified":"2026-11-19T18:42:21","modified_gmt":"2026-11-19T18:42:21","slug":"wheel-of-fortune","status":"publish","type":"post","link":"https:\/\/ioninteractive.com\/ionacademy\/wheel-of-fortune\/","title":{"rendered":"Wheel of Fortune Component"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"contents\">Contents<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\"><a href=\"#installation-workflow\">Installation Workflow<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"#usage-configuration\">Usage Configuration<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"#optional-workflow-winlose-lightboxes\">Optional Workflow: Win\/Lose Lightboxes<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"#testing-checklist\">Testing Checklist<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installation-workflow\">Installation Workflow<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Before you start:<\/strong> Make sure you can upload files in <strong>Libraries &gt; Frameworks<\/strong> and create widgets in <strong>Libraries &gt; Widgets<\/strong>. Create or identify a Text field in <strong>Data Collection &gt; Data Fields<\/strong> to store the spin result, for example <code>WheelResult<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-1-prepare-the-minified-assets-locally\">Step 1: Prepare the minified assets locally<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The CSS and JavaScript are in separate code blocks below. Copy each block into its own plain-text file and save it with the filename shown above that block.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Windows (Notepad):<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"\">Launch Notepad.<\/li>\n\n\n\n<li class=\"\">Copy the <a href=\"#wheel-css-code\">CSS code below<\/a> and paste it into the file.<\/li>\n\n\n\n<li class=\"\">Choose <code>File &gt; Save As<\/code>, set \u201cSave as type\u201d to \u201cAll Files\u201d, select UTF-8 encoding, and save as <code>ixp-ps-widget-wheel-of-fortune.min.css<\/code>.<\/li>\n\n\n\n<li class=\"\">Open a new Notepad window.<\/li>\n\n\n\n<li class=\"\">Copy the <a href=\"#wheel-javascript-code\">JavaScript code below<\/a> and paste it into the new file.<\/li>\n\n\n\n<li class=\"\">Choose <code>File &gt; Save As<\/code>, select \u201cAll Files\u201d and UTF-8, and save as <code>ixp-ps-widget-wheel-of-fortune.min.js<\/code>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>macOS (TextEdit):<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"\">Open TextEdit and select <code>Format &gt; Make Plain Text<\/code>.<\/li>\n\n\n\n<li class=\"\">Copy the <a href=\"#wheel-css-code\">CSS code below<\/a> and paste it into the file.<\/li>\n\n\n\n<li class=\"\">Save the document as <code>ixp-ps-widget-wheel-of-fortune.min.css<\/code>.<\/li>\n\n\n\n<li class=\"\">Create a new plain-text document.<\/li>\n\n\n\n<li class=\"\">Copy the <a href=\"#wheel-javascript-code\">JavaScript code below<\/a> and paste it into the new file.<\/li>\n\n\n\n<li class=\"\">Save the document as <code>ixp-ps-widget-wheel-of-fortune.min.js<\/code>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Linux (Gedit or another plain-text editor):<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"\">Open your preferred plain-text editor (for example, Gedit).<\/li>\n\n\n\n<li class=\"\">Copy the <a href=\"#wheel-css-code\">CSS code below<\/a> and paste it into the file.<\/li>\n\n\n\n<li class=\"\">Save the file as <code>ixp-ps-widget-wheel-of-fortune.min.css<\/code>.<\/li>\n\n\n\n<li class=\"\">Create a second document.<\/li>\n\n\n\n<li class=\"\">Copy the <a href=\"#wheel-javascript-code\">JavaScript code below<\/a> and paste it into the new file.<\/li>\n\n\n\n<li class=\"\">Save the file as <code>ixp-ps-widget-wheel-of-fortune.min.js<\/code>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Any plain-text editor that saves in UTF-8 works. Before uploading, check that the filenames end in <code>.css<\/code> and <code>.js<\/code>, with no extra <code>.txt<\/code> extension.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"wheel-css-code\">CSS for ixp-ps-widget-wheel-of-fortune.min.css<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>div.ixp-ps-widget-wheel-of-fortune{user-select:none;-moz-user-select:none;position:relative;max-width:100%;height:0;padding-bottom:100%}div.ixp-ps-widget-wheel-of-fortune svg{--offset:0;position:absolute;overflow:visible;transition:.2s;transition-timing-function:ease-out;width:100%;height:100%;top:0;left:0}div.ixp-ps-widget-wheel-of-fortune svg&gt;g.wheel{transform:rotate(var(--offset))}div.ixp-ps-widget-wheel-of-fortune svg&gt;g.wheel.spin{animation-name:spin;animation-duration:6s;animation-fill-mode:forwards}div.ixp-ps-widget-wheel-of-fortune svg&gt;g.wheel&gt;g.sector&gt;path{stroke:#fff}div.ixp-ps-widget-wheel-of-fortune svg&gt;g.wheel&gt;g.sector&gt;path:not(&#091;fill]){fill:#0c2032}div.ixp-ps-widget-wheel-of-fortune svg&gt;g.wheel&gt;g.sector&gt;text{fill:#000;writing-mode:tb;text-orientation:upright}div.ixp-ps-widget-wheel-of-fortune svg&gt;g.wheel&gt;g.sector&gt;path:not(&#091;fill])+text{fill:#fff}div.ixp-ps-widget-wheel-of-fortune svg&gt;g.center&gt;path{cursor:pointer;fill:#0c2032;stroke:#fff}div.ixp-ps-widget-wheel-of-fortune svg&gt;g.center&gt;text{cursor:pointer;fill:#fff}div.ixp-ps-widget-wheel-of-fortune svg&gt;g.center&gt;*{transition:.3s}div.ixp-ps-widget-wheel-of-fortune svg&gt;g.center:hover&gt;*{transform:scale(1.3)}@keyframes spin{from{transform:rotate(var(--offset))}to{transform:rotate(var(--target))}}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Updating a wheel you already installed? Replace the framework JavaScript with the version below. To use the optional spin flag, also update the widget embed in Step 3 and add the <strong>Spin Flag Field Name<\/strong> variable. Test in a creative before updating a shared widget.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"wheel-javascript-code\">JavaScript for ixp-ps-widget-wheel-of-fortune.min.js<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>!function(){const svgNamespace=&#091;\"http:\",\"www.w3.org\/2000\/svg\"].join(\"\/\/\");const t=function({onClick:t=(()=&gt;{}),items:e=&#091;],playOnce:n=!1,hasPlayed:r=!1,parent:a}){if(!a)throw new Error(\"No target node provided\");const o={onClick:t,items:e,playOnce:n,hasPlayed:r,parent:a,radius:200,sectorCount:Math.max(e.length,2)},s=(t=1,e=0)=&gt;Math.floor(Math.random()*t)+e,l=({radius:t,sectorCount:e,items:n})=&gt;{const r=document.createElementNS(svgNamespace,\"svg\");r.setAttribute(\"viewBox\",`-${1.2*t} -${1.2*t} ${2.4*t} ${2.4*t}`);const a=360\/e,l=a\/2+180,p=i(n,e),u=document.createElementNS(svgNamespace,\"g\");u.setAttribute(\"class\",\"wheel\"),r.appendChild(u);for(let r=0;r&lt;e;++r){const o=l+a*r,s=l+a*(r+1),c=f(e-r+p,e);d(o,s,u,n&#091;c],t)}return c(r,\"Spin\"),r.addEventListener(\"click\",function(t){switch(t.target.parentNode.getAttribute(\"class\").split(\" \")&#091;0]){case\"center\":((t,{sectorCount:e,playOnce:n,hasPlayed:r,items:a,onClick:l})=&gt;{if(o.spinning||1==n&amp;&amp;1==r)return;o.spinning=!0;const c=360\/e,d=s(e),p=i(a,e),u=f(e-d+p,e),h=`${(e-u)*c+360*s(2,4)}`;t.style.setProperty(\"--target\",h+\"deg\"),y(t,\"spin\").then(e=&gt;{t.style.setProperty(\"--offset\",Math.floor(h%360)+\"deg\"),e.target.classList.remove(\"spin\"),l(a&#091;u],saved=&gt;{o.spinning=!1;if(saved)o.hasPlayed=!0})})})(r.querySelector(\"g.wheel\"),o)}}),r},c=(t,e)=&gt;{const n=document.createElementNS(svgNamespace,\"g\");n.setAttribute(\"class\",\"center\");const r=document.createElementNS(svgNamespace,\"path\");r.setAttribute(\"d\",\"m -9 -24 l 9 -16 l 9 16 a 25 25 0 1 1 -18 0 z\"),n.appendChild(r);const a=u(0,3,e);n.appendChild(a),t.appendChild(n)},i=(t,e)=&gt;t.length&lt;e&amp;&amp;length&lt;4?-2:-1,d=(t,e,n,r,a)=&gt;{const o=document.createElementNS(svgNamespace,\"g\"),s=document.createElementNS(svgNamespace,\"path\");if(s.setAttribute(\"class\",\"sector-path\"),r.backgroundColor&amp;&amp;s.setAttribute(\"fill\",r.backgroundColor),s.setAttribute(\"d\",p(t,e,a)),o.appendChild(s),o.setAttribute(\"class\",\"sector\"),o.setAttribute(\"data-id\",r.id),r.label){const n=h(t,e,1.9*a),s=-1*(t+(e-t)\/2-180),l=u(n.x,n.y,r.label,s,\"start\");o.appendChild(l)}n.appendChild(o)},p=(t,e,n)=&gt;{const r=w(t,n);let a=\"M\"+m(r);return a+=`A${n} ${n} 0 0 0 ${m(w(e,n))}`,a+=\"L 0 0\",a+=\"Z\"},u=(t,e,n,r,a)=&gt;{const o=document.createElementNS(svgNamespace,\"text\");return t=g(t),e=g(e),r=r||0,a=a||\"middle\",o.setAttribute(\"text-anchor\",a),o.setAttribute(\"transform\",`rotate(${r}, ${t}, ${e})`),o.setAttribute(\"x\",t),o.setAttribute(\"y\",e),o.innerHTML=n,o},h=(t,e,n)=&gt;w((t+e)\/2,n\/2),w=(t,e)=&gt;({x:Math.sin(b(t))*e,y:Math.cos(b(t))*e}),m=t=&gt;`${g(t.x)} ${g(t.y)}`,g=t=&gt;{if(Number.isInteger(t))return t.toString();if(t){let e=(+t).toFixed(5);return e.match(\/\\.\/)&amp;&amp;(e=e.replace(\/\\.?0+$\/,\"\")),e}},f=(t,e)=&gt;(t&lt;0&amp;&amp;(t=e+t),t&gt;=e&amp;&amp;(t-=e),t&lt;e?t:null),b=t=&gt;t*(Math.PI\/180),y=(t,e)=&gt;new Promise(function(n){t.addEventListener(\"animationend\",function e(r){t.removeEventListener(\"animationend\",e),n(r)}),t.classList.add(e)});return{create:()=&gt;{const t=l(o);o.parent.appendChild(t)}}};\nconst runtime = window.ixp.runtime;\n\nfunction decodeJson(value) {\n  const div = document.createElement(\"div\");\n  div.innerHTML = value;\n  return JSON.parse(div.textContent);\n}\n\nfunction followAction(action) {\n  if (!action) return;\n  const target = new URL(action, location.href);\n  const current = new URL(location.href);\n  const samePage = target.origin === current.origin &amp;&amp;\n    target.pathname === current.pathname &amp;&amp; target.search === current.search;\n  location.assign(target.href);\n  if (samePage &amp;&amp; (target.hash || current.hash)) location.reload();\n}\n\nfunction initialize({\n  scriptElement, data, dataField, sliceColors = \"\", hasPlayed = \"\",\n  playOnlyOnce = \"\", action = \"\", spinFlagField = \"\"\n}) {\n  const parent = scriptElement.closest(\"div\");\n  parent.classList.add(\"ixp-ps-widget-wheel-of-fortune\");\n  const resultField = dataField.trim();\n  const flagField = spinFlagField.trim();\n  if (!resultField || (flagField &amp;&amp; flagField.toLowerCase() === resultField.toLowerCase())) {\n    console.warn(\"Wheel of Fortune needs a result field and a separate field for the optional spin flag.\");\n    return;\n  }\n\n  let colors = &#091;];\n  if (sliceColors.trim()) {\n    try {\n      colors = decodeJson(sliceColors);\n    } catch (error) {\n      console.warn(\"Wheel of Fortune could not read the optional colors.\", error);\n    }\n  }\n\n  let items;\n  try {\n    const slices = decodeJson(data);\n    if (!Array.isArray(slices) || slices.length &lt; 2) {\n      throw new Error(\"Wheel Contents needs at least two slices.\");\n    }\n    items = slices.map((slice, index) =&gt; {\n      const &#091;label, value] = Object.entries(slice)&#091;0];\n      return { id: label + \"-\" + index, label, value, backgroundColor: colors &amp;&amp; colors&#091;index] };\n    });\n  } catch (error) {\n    console.warn(\"Wheel of Fortune could not read the slice settings.\", error);\n    return;\n  }\n\n  t({\n    parent,\n    items,\n    playOnce: !!playOnlyOnce,\n    hasPlayed: !!hasPlayed,\n    onClick(item, done) {\n      if (runtime.inStudio) {\n        done(true);\n        return;\n      }\n      const data = &#091;{ dataField: JSON.stringify({ name: resultField }), value: item.value }];\n      if (flagField) {\n        data.push({ dataField: JSON.stringify({ name: flagField }), value: true });\n      }\n      runtime.data.save({\n        data,\n        success() {\n          done(true);\n          followAction(action.trim());\n        },\n        error() {\n          done(false);\n          console.warn(\"Wheel of Fortune could not save the spin result.\");\n        }\n      });\n    }\n  }).create();\n}\n\nwindow.ixpPSWidgetDataLayer.forEach((&#091;command, options]) =&gt; {\n  if (command === \"init\") initialize(options);\n});\n}();\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-2-upload-the-framework-assets\">Step 2: Upload the framework assets<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">In Ion, navigate to <code>Libraries &gt; Frameworks &gt; Ion Framework<\/code>. <\/li>\n\n\n\n<li class=\"\">Upload the <code>ixp-ps-widget-wheel-of-fortune.min.css<\/code> and <code>ixp-ps-widget-wheel-of-fortune.min.js<\/code> files you created in Step 1.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"994\" height=\"525\" loading=\"lazy\" src=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-1-upload-files-1.png\" alt=\"\" class=\"wp-image-7906\" srcset=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-1-upload-files-1.png 994w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-1-upload-files-1-300x158.png 300w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-1-upload-files-1-768x406.png 768w\" sizes=\"auto, (max-width: 994px) 100vw, 994px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"641\" loading=\"lazy\" src=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-1-upload-confirm-1024x641.png\" alt=\"\" class=\"wp-image-7908\" srcset=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-1-upload-confirm-1024x641.png 1024w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-1-upload-confirm-300x188.png 300w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-1-upload-confirm-768x481.png 768w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-1-upload-confirm.png 1034w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Confirm both files now appear in the framework list before leaving the screen.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"496\" loading=\"lazy\" src=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-2-framework-list-1024x496.png\" alt=\"\" class=\"wp-image-7910\" srcset=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-2-framework-list-1024x496.png 1024w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-2-framework-list-300x145.png 300w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-2-framework-list-768x372.png 768w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/installation-step-2-framework-list.png 1030w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-3-register-the-widget-in-ion\">Step 3: Register the widget in Ion<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Navigate to <code>Libraries &gt; Widgets<\/code>, click <strong>Create New Widget<\/strong>, and select an existing widget category (or add a new one for the wheel widget).<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"99\" loading=\"lazy\" src=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-1-create-widget-1024x99.png\" alt=\"\" class=\"wp-image-7912\" srcset=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-1-create-widget-1024x99.png 1024w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-1-create-widget-300x29.png 300w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-1-create-widget-768x74.png 768w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-1-create-widget.png 1258w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">In the widget editor, name the widget and confirm its category. Copy the entire <a href=\"#wheel-embed-code\">Widget embed code<\/a>, including the opening and closing <code>&lt;script&gt;<\/code> tags, and paste it into <strong>Widget code &amp; variables<\/strong>. Keep the <code>##<\/code> variable tokens and the <code>{{##dataField}}<\/code> merge field as shown. Set their values when you add the widget to a creative.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"556\" loading=\"lazy\" src=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-2-editor-snippet-1024x556.png\" alt=\"\" class=\"wp-image-7914\" srcset=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-2-editor-snippet-1024x556.png 1024w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-2-editor-snippet-300x163.png 300w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-2-editor-snippet-768x417.png 768w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-2-editor-snippet-940x510.png 940w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-2-editor-snippet-345x187.png 345w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-2-editor-snippet-626x339.png 626w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-2-editor-snippet.png 1251w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"wheel-embed-code\">Widget embed code<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script&gt;\n  (function (d, s, id, src, fjs) {\n    if (d.getElementById(id)) return;\n    fjs = d.getElementsByTagName(s)&#091;0];\n    s = d.createElement(s);\n    s.id = id;\n    s.rel = \"stylesheet\";\n    s.href = src;\n    fjs.parentNode.insertBefore(s, fjs);\n  })(\n    document,\n    \"link\",\n    \"ixp-ps-wof-css\",\n    \"\/Templates\/ion\/ion_Framework_v4.0\/ixp-ps-widget-wheel-of-fortune.min.css\"\n  );\n\n  (function (d, s, id, src, fjs) {\n    if (d.getElementById(id)) return;\n    fjs = d.getElementsByTagName(s)&#091;0];\n    s = d.createElement(s);\n    s.id = id;\n    s.src = src;\n    s.async = true;\n    fjs.parentNode.insertBefore(s, fjs);\n  })(\n    document,\n    \"script\",\n    \"ixp-ps-wof-js\",\n    \"\/Templates\/ion\/ion_Framework_v4.0\/ixp-ps-widget-wheel-of-fortune.min.js\"\n  );\n\n  window.ixpPSWidgetDataLayer = window.ixpPSWidgetDataLayer || &#091;];\n  function ixpPSWidget() {\n    ixpPSWidgetDataLayer.push(arguments);\n  }\n\n  ixpPSWidget(\"init\", {\n    data: ` ##dataJSON `,\n    sliceColors: ` ##colorJSON `,\n    dataField: \"##dataField\",\n    spinFlagField: \"##spinFlagField\",\n    hasPlayed: `{{##dataField}}`,\n    scriptElement: document.currentScript,\n    playOnlyOnce: \"##playOnlyOnce\",\n    action: \"##action\",\n  });\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Ion detects the variable names from the embed code. Use the recommended settings below to configure their labels, types, and required settings.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"501\" loading=\"lazy\" src=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-3-variable-dialog-1024x501.png\" alt=\"\" class=\"wp-image-7916\" srcset=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-3-variable-dialog-1024x501.png 1024w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-3-variable-dialog-300x147.png 300w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-3-variable-dialog-768x376.png 768w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-3-variable-dialog-1536x752.png 1536w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-3-variable-dialog.png 1827w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"887\" height=\"159\" loading=\"lazy\" src=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-3-variable-list.png\" alt=\"\" class=\"wp-image-7918\" srcset=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-3-variable-list.png 887w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-3-variable-list-300x54.png 300w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-3-variable-list-768x138.png 768w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/registration-step-3-variable-list-880x159.png 880w\" sizes=\"auto, (max-width: 887px) 100vw, 887px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">For each detected variable, select <strong>Add Variable<\/strong>. Keep the <strong>Variable<\/strong> name as shown in the table so it matches the embed code. Use the listed <strong>Label<\/strong> so it matches this guide, then choose the <strong>Type<\/strong> and <strong>Required<\/strong> setting shown.<\/li>\n\n\n\n<li class=\"\">Click <strong>OK<\/strong> and repeat for all six variables.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Recommended settings for widget variables in Ion:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Variable<\/strong><\/td><td><strong>Label<\/strong><\/td><td><strong>Type<\/strong><\/td><td><strong>Required<\/strong><\/td><\/tr><tr><td>action<\/td><td>Action Trigger<\/td><td>Action<\/td><td>no<\/td><\/tr><tr><td>colorJSON<\/td><td>Background Colors<\/td><td>Text<\/td><td>no<\/td><\/tr><tr><td>dataField<\/td><td>DataField Name<\/td><td>Text<\/td><td>yes<\/td><\/tr><tr><td>dataJSON<\/td><td>Wheel Contents<\/td><td>Text<\/td><td>yes<\/td><\/tr><tr><td>playOnlyOnce<\/td><td>Can only play once<\/td><td>Text<\/td><td>no<\/td><\/tr><tr><td>spinFlagField<\/td><td>Spin Flag Field Name<\/td><td>Text<\/td><td>no<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Save the widget so it becomes available in creatives.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"#contents\">Back to Contents<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"usage-configuration\">Usage Configuration<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Drag the widget into your creative (<code>Elements palette &gt; Basics &gt; Widget<\/code>), then select the widget name configured above.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"831\" height=\"983\" loading=\"lazy\" src=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/usage-step-1-widget-config.png\" alt=\"\" class=\"wp-image-7920\" srcset=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/usage-step-1-widget-config.png 831w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/usage-step-1-widget-config-254x300.png 254w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/usage-step-1-widget-config-768x908.png 768w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Fill in the widget settings using the values below. Paste each JSON example on one line.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\"><strong>Wheel Contents<\/strong> needs at least two slices. Copy the one-line example below into the field to try it. Each pair gives Ion the label to display and the value to save on the respondent record.<\/li>\n\n\n\n<li class=\"\"><strong>Background Colors<\/strong> is optional. To set custom colors, paste a one-line list in slice order, for example <code>[\"#FFD166\",\"#90E0EF\"]<\/code> for the two slices below.<\/li>\n\n\n\n<li class=\"\"><strong>DataField Name<\/strong> is the exact name of your existing Text field, for example <code>WheelResult<\/code>.<\/li>\n\n\n\n<li class=\"\"><strong>Spin Flag Field Name<\/strong> is optional. Leave it blank for a basic wheel. If you use the lightbox workflow below, enter the name of a separate Text field, for example <code>justSpun<\/code>. Ion sets this field to <code>true<\/code> when it saves a spin result.<\/li>\n\n\n\n<li class=\"\"><strong>Can only play once<\/strong> accepts <code>true<\/code> to limit the respondent to one spin. Leave it blank to allow repeat spins. Any text, including <code>false<\/code>, enables the one-spin limit.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Two-slice example to paste into Wheel Contents<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[{\"Win\":\"win\"},{\"Lose\":\"lose\"}]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Optional 12-slice example<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[{\"Win\":true},{\"Win\":true},{\"Win\":true},{\"Lose\":false},{\"Lose\":false},{\"Lose\":false},{\"Win\":true},{\"Win\":true},{\"Win\":true},{\"Lose\":false},{\"Lose\":false},{\"Lose\":false}]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Tip:<\/strong> If the wheel stays blank, paste the two-slice example again. It needs at least two slices and valid JSON. Edit any custom values in a plain-text editor and keep the finished list on one line.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"#contents\">Back to Contents<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"optional-workflow-winlose-lightboxes\">Optional Workflow: Win\/Lose Lightboxes<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Create two separate Text fields in <strong>Data Collection &gt; Data Fields<\/strong>, for example <code>justSpun<\/code> for the spin flag and <code>ShowWinner<\/code> for the result to display once. Enter <code>justSpun<\/code> in <strong>Spin Flag Field Name<\/strong> and keep <strong>DataField Name<\/strong> set to your result field (for example <code>WheelResult<\/code>). Set <strong>Action Trigger<\/strong> to return to the current page. The wheel follows the action after Ion saves both fields.<\/li>\n\n\n\n<li class=\"\">Add two page-load rules in this order. First, clear <code>ShowWinner<\/code> on every load. Second, if <code>justSpun<\/code> equals <code>true<\/code>, copy the saved result from <code>WheelResult<\/code> to <code>ShowWinner<\/code>, then clear <code>justSpun<\/code>. Keep the saved result in <code>WheelResult<\/code> so the one-spin setting can still use it.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"454\" loading=\"lazy\" src=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-step-2-page-rules-1024x454.png\" alt=\"\" class=\"wp-image-7923\" srcset=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-step-2-page-rules-1024x454.png 1024w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-step-2-page-rules-300x133.png 300w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-step-2-page-rules-768x341.png 768w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-step-2-page-rules.png 1120w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Place two lightboxes under the wheel, set them to open on page load, and hide their launch buttons. Show each lightbox only when <code>ShowWinner<\/code> matches its result exactly. The two-slice example uses <code>win<\/code> and <code>lose<\/code>. The 12-slice example uses <code>true<\/code> and <code>false<\/code>. Neither lightbox should open when <code>ShowWinner<\/code> is empty.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"444\" loading=\"lazy\" src=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-win-settings-1024x444.png\" alt=\"\" class=\"wp-image-7925\" srcset=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-win-settings-1024x444.png 1024w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-win-settings-300x130.png 300w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-win-settings-768x333.png 768w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-win-settings.png 1468w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"529\" loading=\"lazy\" src=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-step-3-show-hide-1024x529.png\" alt=\"\" class=\"wp-image-7927\" srcset=\"https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-step-3-show-hide-1024x529.png 1024w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-step-3-show-hide-300x155.png 300w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-step-3-show-hide-768x397.png 768w, https:\/\/ioninteractive.com\/ionacademy\/wp-content\/uploads\/2025\/10\/optional-lightbox-step-3-show-hide.png 1468w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"#contents\">Back to Contents<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"testing-checklist\">Testing Checklist<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Open a test creative outside Creative Studio as a fresh respondent. Check that both asset URLs from the embed code load, then spin and confirm the configured data field contains the result.<\/li>\n\n\n\n<li class=\"\">With <strong>Can only play once<\/strong> set to <code>true<\/code>, reload the page with a result already saved and confirm a second spin is blocked. With the setting blank, confirm another spin is possible.<\/li>\n\n\n\n<li class=\"\">If you configured an <strong>Action Trigger<\/strong>, verify that the redirect opens the intended page after the result saves, including on a slow connection. For lightboxes, test a win and a loss with fresh respondents. Refresh after each outcome and confirm the lightbox stays closed.<\/li>\n\n\n\n<li class=\"\">Validate any custom slice colors render as expected and contrast with the text labels.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"#contents\">Back to Contents<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Contents Installation Workflow Before you start: Make sure you can upload files in Libraries &gt; Frameworks and create widgets in Libraries &gt; Widgets. Create or identify a Text field in Data Collection &gt; Data [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":9755,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","nfd_image_url":"","nfd_onboarding_generated":"","footnotes":""},"categories":[9],"tags":[2173,2119],"class_list":["post-7901","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-the-interactive-components","tag-advanced","tag-ion-templates"],"_links":{"self":[{"href":"https:\/\/ioninteractive.com\/ionacademy\/wp-json\/wp\/v2\/posts\/7901","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ioninteractive.com\/ionacademy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ioninteractive.com\/ionacademy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ioninteractive.com\/ionacademy\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/ioninteractive.com\/ionacademy\/wp-json\/wp\/v2\/comments?post=7901"}],"version-history":[{"count":6,"href":"https:\/\/ioninteractive.com\/ionacademy\/wp-json\/wp\/v2\/posts\/7901\/revisions"}],"predecessor-version":[{"id":9869,"href":"https:\/\/ioninteractive.com\/ionacademy\/wp-json\/wp\/v2\/posts\/7901\/revisions\/9869"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ioninteractive.com\/ionacademy\/wp-json\/wp\/v2\/media\/9755"}],"wp:attachment":[{"href":"https:\/\/ioninteractive.com\/ionacademy\/wp-json\/wp\/v2\/media?parent=7901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ioninteractive.com\/ionacademy\/wp-json\/wp\/v2\/categories?post=7901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ioninteractive.com\/ionacademy\/wp-json\/wp\/v2\/tags?post=7901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}