Google Tag Manager Integration


Google Tag Manager (GTM) is a powerful tag management system that allows you to manage and deploy marketing tags (snippets of code) on your website without modifying the code directly. By integrating GTM with your SweepWidget giveaways, you can track user interactions, connect multiple analytics platforms, and customize your tracking setup with precision.

What You’ll Track with Google Tag Manager

Once integrated, GTM will receive events pushed to the dataLayer for:

  • Page views – Every time someone views your giveaway page
  • User logins – When participants authenticate to enter
  • Contest entries – When users submit their entry
  • Entry method completions – Each individual action users complete (follow, like, share, etc.)
  • Widget interactions – Refreshes, errors, and other user actions

All SweepWidget events are prefixed with sw_ to keep them organized and prevent conflicts with other tags.

Setting Up GTM Integration

Step 1: Navigate to Google Tag Manager Integration

In your SweepWidget dashboard, go to API Integrations from the left sidebar menu.

Click on Google Tag Manager to open the integration settings.

Step 2: Enter Your Container ID

In the Container ID field, enter your GTM Container ID (it starts with “GTM-” followed by letters and numbers, like GTM-XXXXXX).

Click the Update button to save your settings.

Important: Only enter your Container ID (GTM-XXXXXX), not the entire GTM script.

Finding Your GTM Container ID

If you don’t have a GTM Container ID yet, follow these steps:

Step 1: Access Google Tag Manager

Go to tagmanager.google.com and sign in with your Google account.

Step 2: Create or Select a Container

If you already have a GTM container, select it from your account list. If not, create a new container:

  1. Click Create Account (if you don’t have one) or Create Container (if adding to existing account)
  2. Enter an account name and select your country
  3. Enter a container name (usually your website domain)
  4. Select Web as the target platform
  5. Click Create and accept the terms

Step 3: Copy Your Container ID

Your Container ID is displayed in the top right corner of the GTM interface (format: GTM-XXXXXX). Copy this ID and paste it into the SweepWidget integration field.

Setting Up Tags in GTM

After connecting SweepWidget to GTM, you’ll need to create tags and triggers in GTM to use the event data.

Creating a Trigger for SweepWidget Events

  1. In GTM, go to Triggers and click New
  2. Click on the trigger configuration area
  3. Select Custom Event as the trigger type
  4. In the Event Name field, enter: sw_.* (this will match all SweepWidget events)
  5. Check Use regex matching
  6. Name your trigger (e.g., “SweepWidget – All Events”)
  7. Click Save

Creating a Tag (Example: Send to Google Analytics)

  1. Go to Tags and click New
  2. Click on the tag configuration area
  3. Select Google Analytics: GA4 Event
  4. Enter your GA4 Measurement ID
  5. Set Event Name to: {{Event}} (this uses the event name from the dataLayer)
  6. Add Event Parameters: – Parameter Name: event_category, Value: {{eventCategory}} – Parameter Name: event_label, Value: {{eventLabel}}
  7. In the Triggering section, select your “SweepWidget – All Events” trigger
  8. Name your tag (e.g., “SweepWidget to GA4”)
  9. Click Save

Testing Your GTM Setup

Using Preview Mode

  1. In GTM, click Preview in the top right corner
  2. Enter your giveaway page URL
  3. Click Connect
  4. Interact with your giveaway (login, enter, complete actions)
  5. In the Tag Assistant panel, you should see SweepWidget events (sw_page_view, sw_user_login, sw_contest_entry, etc.) appearing
  6. Click on each event to verify your tags are firing correctly

Publishing Your Container

Once you’ve confirmed everything is working in Preview mode:

  1. Click Submit in the top right
  2. Add a version name and description (e.g., “Added SweepWidget tracking”)
  3. Click Publish

Events Pushed to dataLayer

SweepWidget automatically pushes the following events to the GTM dataLayer:

Event List

Event NameWhen It FiresWhat It Tracks
sw_page_viewUser views giveaway pagePage loads and views
sw_user_loginUser logs in to enterUser authentication
sw_contest_entryUser submits their entryContest entries
sw_insert_entryUser completes an entry methodIndividual actions (like, follow, share, etc.)
sw_reload_widgetUser refreshes the widgetWidget interactions

dataLayer Structure

Each event includes the following data:

  • event – Event name (with sw_ prefix)
  • eventCategory – Category of the action (e.g., “Contest Entry”, “User Login”)
  • eventAction – Action name (same as the event without prefix)
  • eventLabel – Specific details about the action (e.g., “Facebook Like Page”, “Twitter Follow”)

Example dataLayer Push

When a user completes “Insert entry: Facebook Like Page”, the dataLayer receives:

{
  event: "sw_insert_entry",
  eventCategory: "Insert Entry",
  eventAction: "Insert entry",
  eventLabel: "Facebook Like Page"
}

Advanced Use Cases

Sending Events to Multiple Platforms

With GTM, you can send the same SweepWidget events to multiple analytics platforms simultaneously:

  • Google Analytics 4
  • Meta Pixel
  • LinkedIn Insight Tag
  • Hotjar
  • Any custom tracking solution

Simply create multiple tags using the same SweepWidget trigger.

Creating Conversion Triggers

Set up specific triggers for important conversion events:

  • Create a trigger for sw_contest_entry to track contest completions
  • Create a trigger for sw_user_login to track user registrations
  • Use these triggers to fire conversion tags for Google Ads, Facebook Ads, etc.

Troubleshooting

Events Not Appearing in Preview Mode?

If you’re not seeing SweepWidget events in GTM Preview mode:

  • Verify Container ID: Make sure you entered the correct GTM-XXXXXX ID in SweepWidget.
  • Check browser console: Open your browser’s developer tools and look for any JavaScript errors that might be preventing the dataLayer from working.
  • Refresh the page: After connecting Preview mode, refresh your giveaway page to ensure GTM loads properly.
  • Check dataLayer: In the browser console, type dataLayer and press Enter to see if events are being pushed (even if GTM isn’t recognizing them).

Tags Not Firing?

If events appear in the dataLayer but your tags aren’t firing:

  • Check trigger configuration: Make sure you used sw_.* with regex matching enabled for the event name.
  • Verify tag setup: Ensure your tag is properly configured and has the correct trigger attached.
  • Check for conflicts: Some tag blockers or conflicting triggers might prevent tags from firing.
  • Publish your container: Remember that Preview mode shows what WILL happen; you need to publish for changes to go live.

Best Practices

  • Use consistent naming: When creating tags and triggers, use clear, descriptive names that indicate they’re for SweepWidget tracking.
  • Create variables: Set up GTM variables for eventCategory, eventAction, and eventLabel to make tag configuration easier.
  • Test before publishing: Always use Preview mode to verify your setup before publishing to production.
  • Document your setup: Use GTM’s version descriptions to document what changes you make and why.
  • Organize with folders: Group related tags, triggers, and variables into folders for easier management.
  • Monitor performance: Regularly review your tag performance in GTM to ensure everything is working correctly.

Need Help?

If you need assistance setting up Google Tag Manager tracking for your giveaways: