{"id":410,"date":"2022-08-02T15:04:19","date_gmt":"2022-08-02T15:04:19","guid":{"rendered":"https:\/\/www.smashpops.com\/blog\/?page_id=410"},"modified":"2022-10-13T13:39:14","modified_gmt":"2022-10-13T13:39:14","slug":"how-to-send-an-analytics-event-when-someone-has-played-facebook-pixel-for-instance","status":"publish","type":"page","link":"https:\/\/www.smashpops.com\/blog\/how-to-send-an-analytics-event-when-someone-has-played-facebook-pixel-for-instance\/","title":{"rendered":"How to send an analytics event when someone has played? (Facebook Pixel for instance)"},"content":{"rendered":"<p>To send an analytics event when someone has played, for example to Facebook, we&#8217;ll define a function in our HTML that will track the Facebook lead and then have the SmashPops popup call it. You can follow those steps :<\/p>\n<ol>\n<li>In your Shopify admin, go to <strong>Themes<\/strong>, <strong>Actions<\/strong> and <strong>Edit code.<\/strong><br \/>\n<img loading=\"lazy\" class=\"aligncenter wp-image-417 size-large\" src=\"https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics1-1024x485.jpg\" alt=\"\" width=\"1024\" height=\"485\" srcset=\"https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics1-1024x485.jpg 1024w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics1-300x142.jpg 300w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics1-768x364.jpg 768w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics1-1536x728.jpg 1536w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics1-2048x971.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/li>\n<li>Edit <strong>theme.liquid<\/strong>, add the following code to the &lt;head&gt; and hit <strong>Save<\/strong>:<br \/>\n<em>&lt;script&gt;<\/em><br \/>\n<em>window.trackFBLead = function() {<\/em><br \/>\n<em>fbq(&#8216;track&#8217;, &#8216;Lead&#8217;);<\/em><br \/>\n<em>};<\/em><br \/>\n<em>&lt;\/script&gt;<br \/>\n<img loading=\"lazy\" class=\"aligncenter wp-image-422 size-large\" src=\"https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics22-1024x485.jpg\" alt=\"\" width=\"1024\" height=\"485\" srcset=\"https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics22-1024x485.jpg 1024w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics22-300x142.jpg 300w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics22-768x364.jpg 768w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics22-1536x728.jpg 1536w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics22-2048x971.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/em><br \/>\nFor information, the equivalent code for event tracking using Google Analytics would be:<br \/>\n<em>ga(&#8220;send&#8221;, {<\/em><br \/>\n<em>\u00a0 &#8220;hitType&#8221;: &#8220;event&#8221;,<\/em><br \/>\n<em>\u00a0 &#8220;eventCategory&#8221;: &#8220;engagement&#8221;,<\/em><br \/>\n<em>\u00a0 &#8220;eventAction&#8221;: &#8220;spun_wheel&#8221;<\/em><br \/>\n<em>});<\/em><br \/>\nAnd for Google Tag Manager, this would be:<br \/>\n<em>gtag(&#8220;event&#8221;, &#8220;spun_wheel&#8221;, {<\/em><br \/>\n<em>\u00a0 &#8220;event_category&#8221;: &#8220;engagement&#8221;<\/em><br \/>\n<em>});<\/p>\n<p><\/em><\/li>\n<li>Go back to SmashPops, edit your popup and go to <strong>SETTINGS<\/strong> and <strong>Javascript.<\/strong><br \/>\n<img loading=\"lazy\" class=\"aligncenter wp-image-419 size-large\" src=\"https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics3-1024x485.jpg\" alt=\"\" width=\"1024\" height=\"485\" srcset=\"https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics3-1024x485.jpg 1024w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics3-300x142.jpg 300w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics3-768x364.jpg 768w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics3-1536x728.jpg 1536w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics3-2048x971.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/li>\n<li>\u00a0Select <strong>Call a Javascript function &#8230;<\/strong> and check <strong>When the user wins a coupon<\/strong>, enter &#8220;trackFBLead&#8221; in the field and save your popup. From now on, everytime someone successfully submits his email (= wins a coupon), your Facebook pixel will be called.<br \/>\n<img loading=\"lazy\" class=\"aligncenter wp-image-420 size-large\" src=\"https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics4-1024x485.jpg\" alt=\"\" width=\"1024\" height=\"485\" srcset=\"https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics4-1024x485.jpg 1024w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics4-300x142.jpg 300w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics4-768x364.jpg 768w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics4-1536x728.jpg 1536w, https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics4-2048x971.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>To send an analytics event when someone has played, for example to Facebook, we&#8217;ll define a function in our HTML that will track the Facebook lead and then have the SmashPops popup call it. You can follow those steps : In your Shopify admin, go to Themes, Actions and Edit code. Edit theme.liquid, add the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to send an analytics event when someone has played? (Facebook Pixel for instance) - SmashPops Blog<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.smashpops.com\/blog\/how-to-send-an-analytics-event-when-someone-has-played-facebook-pixel-for-instance\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to send an analytics event when someone has played? (Facebook Pixel for instance) - SmashPops Blog\" \/>\n<meta property=\"og:description\" content=\"To send an analytics event when someone has played, for example to Facebook, we&#8217;ll define a function in our HTML that will track the Facebook lead and then have the SmashPops popup call it. You can follow those steps : In your Shopify admin, go to Themes, Actions and Edit code. Edit theme.liquid, add the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.smashpops.com\/blog\/how-to-send-an-analytics-event-when-someone-has-played-facebook-pixel-for-instance\/\" \/>\n<meta property=\"og:site_name\" content=\"SmashPops Blog\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-13T13:39:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics1-1024x485.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.smashpops.com\/blog\/#organization\",\"name\":\"SmashPops\",\"url\":\"https:\/\/www.smashpops.com\/blog\/\",\"sameAs\":[],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.smashpops.com\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2020\/04\/icon1024.png\",\"width\":1024,\"height\":1024,\"caption\":\"SmashPops\"},\"image\":{\"@id\":\"https:\/\/www.smashpops.com\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.smashpops.com\/blog\/#website\",\"url\":\"https:\/\/www.smashpops.com\/blog\/\",\"name\":\"SmashPops Blog\",\"description\":\"Everything you need to know about e-commerce and email collection.\",\"publisher\":{\"@id\":\"https:\/\/www.smashpops.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.smashpops.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.smashpops.com\/blog\/how-to-send-an-analytics-event-when-someone-has-played-facebook-pixel-for-instance\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.smashpops.com\/blog\/wp-content\/uploads\/2022\/08\/sendanalytics1.jpg\",\"width\":2561,\"height\":1214},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.smashpops.com\/blog\/how-to-send-an-analytics-event-when-someone-has-played-facebook-pixel-for-instance\/#webpage\",\"url\":\"https:\/\/www.smashpops.com\/blog\/how-to-send-an-analytics-event-when-someone-has-played-facebook-pixel-for-instance\/\",\"name\":\"How to send an analytics event when someone has played? (Facebook Pixel for instance) - SmashPops Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.smashpops.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.smashpops.com\/blog\/how-to-send-an-analytics-event-when-someone-has-played-facebook-pixel-for-instance\/#primaryimage\"},\"datePublished\":\"2022-08-02T15:04:19+00:00\",\"dateModified\":\"2022-10-13T13:39:14+00:00\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.smashpops.com\/blog\/how-to-send-an-analytics-event-when-someone-has-played-facebook-pixel-for-instance\/\"]}]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.smashpops.com\/blog\/wp-json\/wp\/v2\/pages\/410"}],"collection":[{"href":"https:\/\/www.smashpops.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.smashpops.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.smashpops.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.smashpops.com\/blog\/wp-json\/wp\/v2\/comments?post=410"}],"version-history":[{"count":6,"href":"https:\/\/www.smashpops.com\/blog\/wp-json\/wp\/v2\/pages\/410\/revisions"}],"predecessor-version":[{"id":600,"href":"https:\/\/www.smashpops.com\/blog\/wp-json\/wp\/v2\/pages\/410\/revisions\/600"}],"wp:attachment":[{"href":"https:\/\/www.smashpops.com\/blog\/wp-json\/wp\/v2\/media?parent=410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}