Documentation
Feedback
Guides
App Development

App Development
Getting StartedPixel apps4. Writing the head and body scripts
4. Writing the head and body scripts

Now, it is time to define the scripts that your Pixel app will run on the store website. You can specify scripts that execute inside the <head> and/or <body> tags.

Adding a script to the <head> ensures that it will be executed before any other HTML element is rendered on the page. Although this may affect store performance, it is a good option if your Pixel app relies on the interaction between users and store components. On the other hand, adding a script to the store <body> tag will probably reduce the impact on performance scores. However, this may come at the cost of losing user data. Choose wisely based on the functionality of your Pixel app.

Instructions

  1. Open the pixel/head.html file and replace the provided function with your own.

    If you choose to execute your script inside the <body> tag, rename the head.html file to body.html.

  2. Use the settingsSchema identification key previously defined where applicable. See the following example:


    _10
    <script>
    _10
    // Using via JavaScript
    _10
    var appId = "{{settings.gtmId}}";
    _10
    </script>
    _10
    _10
    _10
    <script src="//foobar.com?gtmId={{settings.gtmId}}"></script>

Contributors
2
Photo of the contributor
Photo of the contributor
+ 2 contributors
Was this helpful?
Yes
No
Suggest Edits (GitHub)
See also
5. Listening to store events
App Development
Contributors
2
Photo of the contributor
Photo of the contributor
+ 2 contributors
On this page