- 3 Minutes to read
- Print
- DarkLight
Smart Pixel Snippets
- 3 Minutes to read
- Print
- DarkLight
Smart Pixel Snippets are modular tracking configurations that define what data to track and when it should be collected. They work with the Smart Pixel Core to execute specific tracking logic for pages, products, or user events.
With Smart Pixel Snippets, you can configure:
What to track (e.g., page URLs, product attributes, user actions).
When and where the snippet executes on your website (e.g., at the start or end of the page load).
How to control execution using rules and positions.
1 Single vs. Multiple Snippets
When using Smart Pixel Snippets, you can choose between two approaches: a single snippet for simplicity or multiple snippets for greater flexibility and control. The right choice depends on the complexity of your tracking requirements and how you want to manage execution rules.
Single Snippet Approach
Consolidate all tracking logic (e.g., page, product, and event tracking) into one snippet.
Ideal for smaller websites or straightforward setups where all tracking rules are uniform.
Best Practice: Always place the track request (the command to send data) as the last step in the snippet configuration. This ensures:
All data from the snippet is collected before it is sent.
Subsequent snippets or tracking logic are not interrupted.
Multiple Snippets Approach
Provides greater flexibility for larger or more complex sites.
Divide tracking logic into separate snippets for specific use cases, such as:
Page Tracking Snippet for general site activity.
Product Tracking Snippet for e-commerce data.
Track Request Snippet dedicated solely to sending the collected data.
Assign each snippet to specific rules, allowing you to:
Enable page tracking on all pages.
Restrict product tracking to product-related pages.
Guarantee the track request runs last, ensuring comprehensive data collection.
Best Practice for Track Request Snippet:
Ensure the track request is sent only after all other snippets have executed.
If the track request snippet is set to execute too early (e.g., before other snippets placed “After Closing Body Tag”), those later snippets will not be executed, resulting in incomplete tracking.
2 How to Create and Add a New Snippet
Navigate to Smart Pixel Snippets: In the main menu, click Smart Pixel Snippets and then New Smart Pixel Snippet.
Define Snippet Basics:
Name: Provide a descriptive name for the snippet.
Position: Specify when the snippet will be loaded:
Instantly: Executes as soon as conditions are met.
Head: Executes during the initial page load.
After Body Tag: Executes immediately after the opening <body> tag.
Before Closing Body Tag: Executes at the end of the page load.
Use the Smart Pixel Code Generator: The Smart Pixel Code Generator consists of five sections to configure your tracking setup:
Code: Quickly initialize the Smart Pixel and manage advanced configuration options. This section includes a code box that visualizes how the configured Smart Pixel will look. Note that this code box is for reference only and does not need to be copied.
Configuration: Map the necessary data from the Parameter section (based on Data Layer information) or add static values directly.
Tracking Data: Define the specific tracking requests for your pages, such as events or product interactions.
Integrated Extensions: Track additional relevant data, such as custom JavaScript or enhanced integrations.
Track: Finalize the setup and ensure the data is sent. For single snippets, always include the track request in this section. For multiple snippets, create a separate Track Request Snippet and ensure it executes last.
Organize Your Tracking Setup: Use drag-and-drop functionality in the Smart Pixel Code Generator to reorder Smart Pixel calls, ensuring proper execution order.
Save and Add to the Container:
Once the snippet configuration is complete, save it.
Add the snippet to your container to activate it.
3 How to Edit an Existing Snippet
Locate the Snippet: Navigate to the Smart Pixel Snippets section outside the container to find the snippet you want to edit.
Edit the Snippet Configuration:
Make the necessary changes using the Smart Pixel Code Generator.
Versioning Note: If the snippet is already used in a container, editing it creates a new version of the snippet.
Update the Snippet in the Container:
Go back to the container where the snippet is used.
Replace the old version of the snippet with the updated version.
Save the container to apply the changes.
Key Considerations
Editing Limitations: Once added to a container, snippets cannot be edited directly within the container. Changes must be made in the Smart Pixel Snippets section, and the container must be updated with the new version.
Mapping Data: In the Configuration section of the Code Generator, use Parameters for dynamic data from the Data Layer or add static values for specific use cases.
Track Request Placement: Ensure the track request is the last element executed:
In single snippets, always include it at the end of the configuration.
In multiple snippets, use a dedicated snippet for the track request, executed Before Closing Body Tag.
Testing: Always test snippets in a staging environment to validate their execution order and ensure accurate data collection.