Science & discovery
Static electricity is a charge imbalance.
When certain materials contact and separate, electrons can transfer between them. The resulting charge imbalance can produce attraction or a spark.
The idea
The tiny shock after crossing a carpet is charge finding a path to equalize.