The Tracking Nightmare: How I Finally Made My Shopify App Work with Meta Pixel & Google Analytics

The Tracking Nightmare: How I Finally Made My Shopify App Work with Meta Pixel & Google Analytics

Part 3 of my Partial COD Shopify App Journey


If you've been following along, you know I built a custom Partial COD app for Shopify that was already handling customer details, partial payments, and order creation like a charm. I thought I was done. I was ready to celebrate.

But then reality hit me.

As someone who runs paid ads regularly (and had already gotten decent orders within the first week of launching), I knew something crucial was missing: tracking data. Without Meta Pixel and Google Analytics events firing correctly, I was flying blind. And in the world of paid advertising, more data equals better performance. It's that simple.

So I rolled up my sleeves to add tracking to my app. "This will be easy," I thought. "Just a quick afternoon task."

Spoiler alert: It wasn't.

Approach #1: The GTM Shortcut That Wasn't

Since I was already using Google Tag Manager, my first instinct was straightforward: just call the events from within my app, and GTM would handle the rest. Clean. Simple. Elegant.

And it actually worked... sort of.

The events were firing. Google Analytics was picking them up. I could see the data flowing in beautifully. For a brief moment, I felt like a genius.

Then I checked Meta Pixel. Nothing. Radio silence.

This made zero sense. The same GTM triggers that worked for Google Analytics weren't firing the Meta Pixel tags. I spent hours going back and forth, debugging code, checking configurations, pulling my hair out. If the triggers were working, why wasn't Meta responding?

That's when I realized I might need to take a more direct approach.

Approach #2: Going Straight to the Source

Fine. If GTM wasn't cooperating with Meta, I'd just write the Facebook Pixel code directly into my app. I added the fbq() functions, confident this would solve everything.

It didn't.

The pixel still wasn't firing. Even stranger, my console started throwing errors saying the pixel code wasn't properly configured. But it was! I had double-checked everything.

Now I was really confused. Two different approaches, two different failures. What was I missing?

Approach #3: The Shopify Native Way

Then it hit me—I'm building on Shopify. Surely they have their own API for triggering events, right? Different naming conventions, but same concept.

I pivoted to using Shopify's native event triggering system. This had to be it. This was the platform-approved way.

Heads up: That didn't work either.

The Lightbulb Moment

After burning through three approaches and countless hours, I finally had my breakthrough. And honestly, it was one of those "face-palm" moments where the answer was obvious in hindsight.

The problem? My app was a third-party application running on my own server, outside of Shopify's ecosystem. Shopify couldn't trigger these events because they were happening externally. The platform had no visibility into what my server was doing.

Approach #4: The Solution That Actually Worked

The answer was beautifully simple: bring the tracking into the app itself.

I redesigned the Partial COD admin interface to ask users for their Meta Pixel ID and GTM tag ID directly. Instead of relying on Shopify's environment or external configurations, my app would use these IDs to trigger events from within its own context.

And just like that... it worked.

After three failed attempts, I finally had a solution. The relief was incredible.

What Events Are Actually Tracking?

Now that the system was working, I configured two critical events:

  1. InitiateCheckout (or begin_checkout in Google's language) - Fires when a customer is redirected to the payment gateway, right before they complete their partial payment

  2. Purchase - Triggers immediately after successful payment completion

I was literally dancing around my room when I saw both events firing successfully. Victory at last!

Until I looked at the console logs.

The Final Hurdle

The events were firing, but they weren't sending any data. No transaction details, no customer information, nothing. My celebration came to an abrupt halt.

Fortunately, this was the easiest problem to solve. It was just a JSON structure issue—making sure the right data was being packaged and sent with each event. A few adjustments later, and boom: complete tracking with full order details.

Why I'm Not Making This App Public (Yet)

Currently, this app is running exclusively on my store at bassface.in. You might be wondering why I'm not releasing it commercially, especially after all this work.

The answer is security.

For the payment gateway integration to work for other merchants, they'd need to share their PG API keys with my system. I explored numerous solutions for encrypting and protecting these keys, but everything felt too complex or compromised security in some way.

I'm not comfortable asking merchants to trust me with their API keys until I have a bulletproof security solution. While workarounds exist, they require more development effort than I'm willing to invest right now—especially without proven demand and real-world use cases.

The best use case? Using your own product. So that's exactly what I'm doing.

Once I validate the app's value on my own store and figure out an airtight way to handle API key security, I'll consider making it available to other merchants.

The Lessons

Building this app taught me that sometimes the solution isn't more complex—it's just different. When you're working across platforms and third-party integrations, understanding the boundaries of each system is crucial.

Also, never underestimate tracking implementation. What seems like a "quick add-on" can turn into the most challenging part of your entire project.

Your Turn

This was my first app build, complete with all its frustrations and victories. If you've built your first app, I'd love to hear about your journey. What unexpected challenges did you face? What made you want to give up, and what kept you going?

Let's build together. Drop your story in the comments, and let's learn from each other.

Until next time,
See you in my next blog soon.


This is Part 3 of my Shopify Partial COD App series. If you haven't read the previous parts, start there for the full context of this journey.

S
By Shreyans Jain
Last updated: Oct 1, 2025
Comments
0

Join the conversation

Sign in with Google or GitHub to share your thoughts

Loading comments...