Skip to content

Instantly share code, notes, and snippets.

@shawncreed
Last active March 18, 2019 18:37
Show Gist options
  • Select an option

  • Save shawncreed/152cfa739f1ba0f2a6ee32d1f804895d to your computer and use it in GitHub Desktop.

Select an option

Save shawncreed/152cfa739f1ba0f2a6ee32d1f804895d to your computer and use it in GitHub Desktop.

Revisions

  1. shawncreed revised this gist Mar 18, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions setcookie.example.html
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,8 @@ <h1>Set cookie example</h1>
    * a pixel to set the cookie on the other domain
    */
    var img = document.createElement('img');
    img.height = 1;
    img.width = 1;
    img.src = 'https://www.mybank.com/setcookie.php?userid=' + digitalData.user.userid;
    </script>
    </body>
  2. shawncreed created this gist Mar 18, 2019.
    24 changes: 24 additions & 0 deletions setcookie.example.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    <html>
    <head>
    <title>Set cookie example</title>
    </head>
    <body>
    <h1>Set cookie example</h1>
    This is a page on the site where the cookie is already available.
    <script language="javascript">
    /* This is where our data layer is being set */
    digitalData = {
    user: {
    userid: 'a3cceba83235dc95f750108d22c14731'
    }
    };
    </script>
    <script language="javascript">
    /* This is where we can pull the value from the data layer to populate
    * a pixel to set the cookie on the other domain
    */
    var img = document.createElement('img');
    img.src = 'https://www.mybank.com/setcookie.php?userid=' + digitalData.user.userid;
    </script>
    </body>
    </html>